How to Install and Use Chrony in Linux

Chrony is a flexible implementation of the Network Time Protocol (NTP). It is used to synchronize the system clock from different NTP servers, reference clocks or via manual input.

It can also be used NTPv4 server to provide time service to other servers in the same network. It is meant to operate flawlessly under different conditions such as intermittent network connection, heavily loaded networks, changing temperatures which may affect the clock of ordinary computers.

Chrony comes with two programs:

  • chronyc – command line interface for chrony
  • chronyd – daemon that can be started at boot time

In this tutorial we are going to show you how to install and use Chrony on your Linux system.

Install Chrony in Linux

On some systems, chrony may be installed by default. Still if the package is missing, you can easily install it. using your default package manager tool on your respective Linux distributions using following command.

# yum -y install chrony    [On CentOS/RHEL]
# apt install chrony       [On Debian/Ubuntu]
# dnf -y install chrony    [On Fedora 22+]

To check the status of chronyd use the following command.

# systemctl status chronyd      [On SystemD]
# /etc/init.d/chronyd status    [On Init]

If you want to enable chrony daemon upon boot, you can use the following command.

 
# systemctl enable chronyd       [On SystemD]
# chkconfig --add chronyd        [On Init]

Check Chrony Synchronization in Linux

To check if chrony is actually synchronized, we will use it’s command line program chronyc, which has the tracking option which will provide relevant information.

# chronyc tracking
Check Chrony Synchronization in Linux
Check Chrony Synchronization in Linux

The listed files provide the following information:

  • Reference ID – the reference ID and name to which the computer is currently synced.
  • Stratum – number of hops to a computer with an attached reference clock.
  • Ref time – this is the UTC time at which the last measurement from the reference source was made.
  • System time – delay of system clock from synchronized server.
  • Last offset – estimated offset of the last clock update.
  • RMS offset – long term average of the offset value.
  • Frequency – this is the rate by which the system’s clock would be wrong if chronyd is not correcting it. It is provided in ppm (parts per million).
  • Residual freq – residual frequency indicated the difference between the measurements from reference source and the frequency currently being used.
  • Skew – estimated error bound of the frequency.
  • Root delay – total of the network path delays to the stratum computer, from which the computer is being synced.
  • Leap status – this is the leap status which can have one of the following values – normal, insert second, delete second or not synchronized.

To check information about chrony’s sources, you can issue the following command.

# chronyc sources
Check Chrony Sources
Check Chrony Sources

Configure Chrony in Linux

The configuration file of chrony is located at /etc/chrony.conf or /etc/chrony/chrony.conf and sample configuration file may look something like this:

server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

stratumweight 0
driftfile /var/lib/chrony/drift
makestep 10 3
logdir /var/log/chrony

The above configuration provide the following information:

  • server – this directive used to describe a NTP server to sync from.
  • stratumweight – how much distance should be added per stratum to the sync source. The default value is 0.0001.
  • driftfile – location and name of the file containing drift data.
  • Makestep – this directive causes chrony to gradually correct any time offset by speeding or slowing down the clock as required.
  • logdir – path to chrony’s log file.

If you want to step the system clock immediately and ignoring any adjustments currently being in progress, you can use the following command:

# chronyc makestep

If you decide to stop chrony, you can use the following commands.

# systemctl stop chrony          [On SystemD]
# /etc/init.d/chronyd stop       [On Init]
Conclusion

This was a show presentation of the chrony utility and how it can be used on your Linux system. If you wish to check more details about chrony, do review chrony documentation.

Marin Todorov
I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

5 thoughts on “How to Install and Use Chrony in Linux”

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.