CentOS / RHEL 7 : Configuring NTP using chrony

  • Chrony provides another implementation of NTP.
  • Chrony is designed for systems that are often powered down or disconnected from the network.
  • The main configuration file is /etc/chrony.conf.
  • Parameters are similar to those in the /etc/ntp.conf file.
  • chronyd is the daemon that runs in user space.
  • chronyc is a command-line program that provides a command prompt and a number of commands. Examples:
    • tracking: Displays system time information
    • sources: Displays information about current sources.

Installing Chrony

Install the chrony package by using the following command:

# yum install chrony

Use the following commands to start chronyd and to ensure chronyd starts at boot time:

# systemctl start chronyd
# systemctl enable chronyd

Configuring Chrony

A sample configuration would look like below :

# cat /etc/chrony.conf
server a.b.c offline
server d.e.f offline
server g.h.i offline
keyfile /etc/chrony.keys generatecommandkey
driftfile /var/lib/chrony/drift makestep 10 3

The parameters are described as follows:

  • server: Identifies the NTP servers you want to use. The offline keyword indicates that the servers are not contacted until chronyd receives notification that the link to the Internet is present.
  • keyfile: File containing administrator password. Password allows chronyc to log in to chronyd and notify chronyd of the presence of the link to the Internet.
  • generatecommandkey: Generates a random password automatically on the first chronyd start.
  • driftfile: Location and name of file containing drift data.
  • makestep: Step (start anew) system clock if a large correction is needed. The parameters 10 and 3 would step the system clock if the adjustment is larger than 10 seconds, but only in the first three clock updates.

Although, all these parameters are not required. For this post purpose I am using only below two lines in the configuration file.

# cat /etc/chrony.conf
allow 192.0.2/24

Starting chrony

Use the systemctl command to start the chrony daemon, chronyd.

# systemctl start chronyd


To check if chrony is synchronized, use the tracking, sources, and sourcestats commands. Run the chronyc tracking command to check chrony tracking. Alternatively you could run chronyc to display a chronyc> prompt, and then run the tracking command from the chronyc> prompt.

# chronyc tracking
Reference ID : (
Stratum : 12
Ref time (UTC) : Fri Aug 05 19:06:51 2016
System time : 0.000823375 seconds fast of NTP time
Last offset : 0.001989304 seconds
RMS offset : 0.060942811 seconds
Frequency : 1728.043 ppm slow
Residual freq : 1.100 ppm
Skew : 94.293 ppm
Root delay : 0.000207 seconds
Root dispersion : 0.016767 seconds
Update interval : 65.1 seconds
Leap status : Normal

Some of the important fields are :
Reference ID: This is the reference ID and name (or IP address) if available, of the server to which the computer is currently synchronized.
Stratum: The stratum indicates how many hops away from a computer with an attached reference clock you are.
Ref time: This is the time (UT C) at which the last measurement from the reference source was processed.

Run the chronyc sources command to display information about the current time sources that chronyd is accessing.

# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================
^* 11 6 377 63 +1827us[+6783us]...

Some of the fields are described:
M: The mode of the source. ^ means a server, = means a peer, and # indicates
a locally connected reference clock.
S: The state of the sources. “*” indicates the source to which chronyd is currently synchronized. “+” indicates acceptable sources that are combined with the selected source. “-” indicates acceptable sources that are excluded by the combining algorithm. “?” indicates sources to which connectivity has been lost or whose packets do not pass all tests. “x” indicates a clock that chronyd thinks is a false ticker, that is, its time is inconsistent with a majority of other sources. “~” indicates a source whose time appears to have too much variability. The “?” condition is also shown at start-up, until at least three samples have been gathered from it.
Name/IP address: This shows the name or the IP address of the source, or reference ID for reference clocks.

Run the chronyc sourcestats command. This command displays information about the drift rate and offset estimation
process for each of the sources currently being examined by chronyd.

# chronyc sourcestats
210 Number of sources = 1
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev ================================================================================== 5 4 259 -747.564 1623.869 -2873us 30ms

Stop chrony

Use the systemctl command to stop the chrony daemon, chronyd.

# systemctl stop chronyd

Run the chronyc tracking command and notice chronyc cannot talk to the chronyd daemon.

# chronyc tracking
506 Cannot talk to daemon

See also