Bootstrap FreeKB - Chrony - Install Chrony on Linux
Chrony - Install Chrony on Linux

Updated:   |  Chrony articles

If our Linux is a VM running on VMWare's vSphere, ensure that the VM is not using vSphere for time synchronization.

  • Launch vSphere Client
  • Right-click on the VM, and select open console.  The VM console window will appear.
  • In the top menu of the VM console window, click VM and select Edit Settings.  The Virtual Machine Properties pop-up box appears.
  • In the Virtual Machine Properties pop-up box, click the Options Tab.
  • In the Options Tab, highlight VMware Tools in the left panel, and ensure that Synchronize guest time with host in the right panel is not check-marked.  Click OK to close the Virtual Machine Properties pop-up box.

 

On a Red Hat 7 distribution, the yum list installed command can be used to determine if Chrony is installed.

yum list installed | grep -i chrony

 

On a Red Hat 8 distribution, the dnf list installed command can be used.

dnf list installed | grep -i chrony

 

If Chrony is not installed, the yum install or dnf install command can be used to install Chrony.

dnf 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.

  • server 0.fedora.pool.ntp.org iburst
  • server 1.fedora.pool.ntp.org iburst
  • server 2.fedora.pool.ntp.org iburst
  • server 3.fedora.pool.ntp.org iburst

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.

  1. In Terminal, enter nano /etc/chrony.conf or /etc/chrony/chrony.conf.
  2. Below the 4 default NTP servers, add server pool.ntp.org iburst
  3. Press Ctrl O and then Enter to save the changes
  4. Press Ctrl X to exit the nano editor

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.

  • #allow 192.168/16

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.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 528073 in the box below so that we can be sure you are a human.