How To Install and Configure Chrony in Linux

In this article, we want to teach you How To Install and Configure 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 timely service to other servers in the same network.

How To Install and Configure Chrony in Linux

In this article, you will learn to install and configure Chrony in your Linux system.

Also, Chrony comes with two programs:

  1. chronyc: command-line interface for Chrony.
  2. chronyd: service that can be started at boot time.

Let’s start to install Chrony in Linux.

Install Chrony in Linux

On some systems, Chrony may be installed by default.

If the package is missing, you can easily install it with your default package manager tool on your Linux distribution.

You can use the following commands to install Chrony:

In Centos / RHEL Run the following command:

yum -y install chrony

In Debian / Ubuntu run the following command:

apt install chrony

Now you can check the status of chronyd in Linux.

On systemd you can use the following command:

systemctl status chronyd

On init you can use the following command:

/etc/init.d/chronyd status

If you want to enable Chrony service upon boot in Linux:

You can use the following command on systemd:

systemctl enable chronyd

Use the following command on init:

chkconfig --add chronyd

Now let’s check the Chrony synchronization in Linux.

Check the Chrony synchronization in Linux

To check that Chrony is actually synchronized, you can use the chronyc command-line program. It has a tracking option that will provide related information.

To do this run the following command:

chronyc tracking

Your output should similar to this:

Output
Reference ID : CFC5577C (time.cloudflare.com)
Stratum : 4
Ref time (UTC) : Mon Oct 18 09:28:03 2021
System time : 0.000000395 seconds fast of NTP time
Last offset : +0.000000225 seconds
RMS offset : 0.000000225 seconds
Frequency : 1.776 ppm fast
Residual freq : -5.148 ppm
Skew : 1000000.000 ppm
Root delay : 0.037631158 seconds
Root dispersion : 67.812255859 seconds
Update interval : 1.1 seconds
Leap status : Normal

These options of Chrony tracking in Linux 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 the 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 the reference source and the frequency currently being used.

Skew: estimated error bound of the frequency.

Root delay: a 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.

Also, you can check the Chrony sources in Linux with the following command:

chronyc sources

In your output you will see something similar to this:

Output
210 Number of sources = 7
MS Name/IP address            Stratum  Poll Reach  LastRx   Last sample
===============================================================================
^- chilipepper.canonical.com  2        7    377    49       +318us[ +318us] +/- 47ms
^+ golem.canonical.com        2        6    377    52       +304us[ +304us] +/- 52ms
^- alphyn.canonical.com       2        7    377    119      -2712us[-2705us] +/- 115ms
^+ pugot.canonical.com        2        7    377    121      -2609us[-2602us] +/- 43ms
^+ time.xindi.eu              2        7    377    126      +2733us[+2739us] +/- 62ms
^+ time.xindi.eu              2        7    377    58       -2022us[-2022us] +/- 68ms
^* time.cloudflare.com        3        6    377    61       +770us[ +780us] +/- 19ms

When you are done with these, let’s start to configure Chrony in Linux.

Configure Chrony in Linux

The configuration file of Chrony is at the /etc/chrony.conf or /etc/chrony/chrony.conf. open the file with the following command:

vi /etc/chrony/chrony.conf

Your sample Chrony configuration file in Linux may look like this:

pool ntp.ubuntu.com        iburst maxsources 4
pool 0.ubuntu.pool.ntp.org iburst maxsources 1
pool 1.ubuntu.pool.ntp.org iburst maxsources 1
pool 2.ubuntu.pool.ntp.org iburst maxsources 2
keyfile /etc/chrony/chrony.keys
driftfile /var/lib/chrony/chrony.drift
logdir /var/log/chrony
maxupdateskew 100.0
rtcsync
makestep 1 3

Pool directive is used to describe an NTP server to sync from.

driftfile is the location and name of the file containing drift data.

makestep causes Chrony to gradually correct any time offset by speeding or slowing down the clock as required.

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

chronyc makestep

Also, to stop the Chrony in Linux you can use the following command:

On systemd:

systemctl stop chrony

On init:

/etc/init.d/chronyd stop

Conclusion

At this point, you learn to install and use Chrony. chronyd can work well when external time references are only intermittently accessible. chronyd can perform well even when the network is congested for longer periods of time.

Hope you enjoy this article about How to Install and Configure Chrony in Linux.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular