Open In App

How to Install and Use Chrony in Linux?

Last Updated : 05 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

chrony is a flexible Network Time Protocol implementation (NTP). It can sync the system clock with NTP servers, reference clocks (such as a GPS receiver), and manual input via wristwatch and keyboard. It can also act as an NTPv4 (RFC 5905) server and peer, allowing other computers on the network to receive timely updates.

A local server must use an NTP client to get the correct time from a remote NTP server. One such customer is Chrony. Chrony is an excellent option for this reason because it is designed to operate in a variety of situations, including unreliable and/or highly congested network connections, as well as other adverse conditions. At boot time, Chrony synchronizes the computer’s internal clock with higher Stratum NTP servers, a reference clock, or the computer’s real-time clock. Using a wristwatch and a keyboard, it can also be manually synchronized with the input. This is not the most reliable form of synchronization, and it is strongly discouraged.

On a LAN, the precision between two synchronized machines is usually within a few milliseconds. Chrony is divided into two systems: chronyc and chronyd.

  • Chronyc is a command-line interface for monitoring and tweaking chronyd’s output.
  • Chronyd is a background-running daemon that starts and activates the chrony NTP service and tracks the time and status of the time-server.

The chrony.conf file specifies the time NTP server that chronyd tracks. The primary feature of the Chronyd system is to obtain accurate time from one of the major NTP server sources. If the server time is off, chronyd will adjust the device clock to compensate.

Chrony includes two programs:

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

How to Install Chrony in Linux:

Chrony may be installed by default on certain devices. And if the kit is missing, it is simple to install. Using the command below, use your default package manager utility on your respective Linux distributions.

# yum -y install chrony    [On CentOS/RHEL]
# apt install chrony       [On Debian/Ubuntu]
# dnf -y install chrony    [On Fedora 22+]
How to Install and Use Chrony in Linux

installing chrony

To check the status of chronyd use the following command:

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

Enable chrony daemon upon boot with the following command:

  • 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 — Total of the network path delays to the stratum computer, from which the computer is being synced.
  • Leap status — this is the leap status that can have one of the following values – normal, insert second, delete second, or not synchronized.
# systemctl enable chronyd       [On SystemD]
# chkconfig --add chronyd        [On Init]

To Check Chrony Synchronization in Linux:

We’ll use chrony’s command-line software, chronyc, to see whether it’s actually synchronized. It has a monitoring feature that will provide useful details.

# chronyc tracking
How to Install and Use Chrony in Linux

result of  Check Chrony Synchronization 

The listed files provide the following information:-

  • 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 — 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.
  • 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).

To check information about chrony’s sources:

# chronyc sources
How to Install and Use Chrony in Linux

Check Chrony Sources

Configure Chrony in Linux:

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

How to Install and Use Chrony in Linux

The above configuration provides the following information:

  • Server — this directive used to describe an 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:

# 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]

This was a demonstration of the chrony utility and how to use it on a Linux system.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads