If our Linux is a VM running on VMWare's vSphere, ensure that the VM is not using vSphere for time synchronization.
Use the yum install or apt-get install command to install Chrony NTP client/server on Linux.
apt-get install chrony
yum install chrony
Depending on the Linux distro you are using, the configuration file for chrony is located at /etc/chrony.conf or /etc/chrony/chrony.conf. Our Linux machine can be configured to only be an NTP client, which means that we will use NTP to sychronize time. Our Linux machine can also be configured as both an NTP client and an NTP server. When configured as an NTP server, other computers can make connections to our computer to synchronize time. If we do not make any changes to the chrony configuration file, our machine will be an NTP client only. At the very beginning of the chrony.conf file are a few NTP servers.
These are the 4 NTP servers chrony utilizes by default to synchronize time. It is entirely possible to use different NTP servers, such as time.apple.com. If you will be using a different NTP server as the preferred NTP server, list the preferred NTP server before the 4 default NTP servers. We want to also add pool.ntp.org as the last NTP server. We list pool.ntp.org last because it is the least desireable NTP server, but the most likely NTP server to be available.
The /etc/chrony.conf file will also have the allow option commented out. As an example, if you were part of a 192.168.x.x network, the /etc/chrony.conf file would contain the following listing.
By having this option commented out, our Linux machine will only be an NTP client. If we were to uncomment this line, this would start the process of our Linux machine being an NTP server.
Because we have made changes to the chrony configuration file, we need to restart the chrony daemon. Depending on your Linux distro, one of the two following commands will restart the chrony daemon.
The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.
If your system is using systemd, use the systemctl command to start and enable chronyd.
systemctl restart chronyd
systemctl status chronyd
If your system is using init, use the service command to start and enable chronyd.
service chronyd restart
service chronyd status
We can then verify that the chrony daemon is running. Again, depending on your Linux distro, one of the following two commands will show the status of the chrony daemon.
systemctl status chronyd
service chrony status
We can also use the chronyc sources command to verify that chrony is using our preferred and backup NTP servers. In this example, I have only one NTP server listed in my chrony configuration file, thus the chronyc sources command shows the one NTP server.
We can also use the chronyc tracking command to verify that we are synchronized. If leap status is normal, we are synchronized. On the other hand, if leap status is not synchronized, we are not synchronized.
Lastly, we can issue the date command to display the current date and time, and compare the date and time listed to a world clock to know if we are synchronized.