How to Sync Time in CentOS 8 using Chrony

Chrony is an implementation of the Network Time Protocol. It is used to synchronize the system clock from different NTP servers, reference clocks or via manual input. It runs on Unix-like operating systems and is released under the GNU GPL v2.

Install Chrony

To Install Chrony use the following command:

yum install chrony -y

Testing Chrony

Let's sync time of our centOS server with the remote NTP server manually. You can get a list of NTP Servers from https://www.ntppool.org/en/ -- It is recommended to select a NTP server located closest to your server location.

For Europe,

chronyd -q 'server 0.europe.pool.ntp.org iburst'

For North America,

chronyd -q 'server 0.north-america.pool.ntp.org iburst'

Start and Enable Chronyd Service

Start the chronyd service and setup chronyd to automatically start on reboots using the following commands,

systemctl start chronyd

systemctl enable chronyd

Output:

[root@my ~]# systemctl start chronyd
[root@my ~]# systemctl enable chronyd
[root@my ~]# systemctl status chronyd
● chronyd.service - NTP client/server
     Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor pre>
     Active: active (running) since Wed 2020-03-18 09:33:19 EDT; 25min ago
         Docs: man:chronyd(8)
                     man:chrony.conf(5)
 Main PID: 1688 (chronyd)
        Tasks: 1 (limit: 11533)
     Memory: 1012.0K
     CGroup: /system.slice/chronyd.service
                     └─1688 /usr/sbin/chronyd

Verify and Track Chrony Synchronization

Check that your system’s time is synchronized using chrony now.

chronyc tracking

Output:

[root@my ~]# chronyc tracking
Reference ID    : D58800FC (ntp4.bit.nl)
Stratum         : 2
Ref time (UTC)  : Wed Mar 18 14:00:26 2020
System time     : 0.000005412 seconds fast of NTP time
Last offset     : +0.000027441 seconds
RMS offset      : 0.000032782 seconds
Frequency       : 0.552 ppm slow
Residual freq   : -0.001 ppm
Skew            : 0.083 ppm
Root delay      : 0.005957527 seconds
Root dispersion : 0.000338914 seconds
Update interval : 128.9 seconds
Leap status     : Normal
[root@my ~]#

From the above output,

  • "Reference ID" is the ID / name of the server with which your system’s time is currently synced.
  • "Stratum" is used here to indicate the number of hops away from reference clock we are, or simply, the number of hops between us and remote server we are connected to

Check Chrony Sources

List time sources used by chronyd.

chronyc sources

Output:

[root@my ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ schnitzel.team                2   8   377    99   +866us[ +866us] +/-   10ms
^- gowest.hojmark.net            2   7   377    32    +57us[  +57us] +/-   29ms
^* ntp4.bit.nl                   1   8   377   222   -118us[  -91us] +/- 3273us
^- ntp2k.versadns.com            2   8   377   226  +3607us[+3634us] +/-  108ms
[root@my ~]#

Check Chrony Source Statistics

List drift speed and offset estimation of each source that is used by chronyd.

chronyc sourcestats -v

Output:

[root@my ~]# chronyc sourcestats -v
210 Number of sources = 4
                              .- Number of sample points in measurement set.
                             /    .- Number of residual runs with same sign.
                            |    /    .- Length of measurement set (time).
                            |   |    /      .- Est. clock freq error (ppm).
                            |   |   |      /           .- Est. error in freq.
                            |   |   |     |           /         .- Est. offset.
                            |   |   |     |          |          |   On the -.
                            |   |   |     |          |          |   samples. \
                            |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
schnitzel.team             17   5   23m     +0.206      1.338   +584us   537us
gowest.hojmark.net         22  11   25m     +0.260      1.013   +332us   510us
ntp4.bit.nl                25  13   31m     +0.001      0.074    +95ns    50us
ntp2k.versadns.com         25  13   31m     -0.160      0.435  +4230us   285us
[root@my ~]#

You have now successfully synced your CentOS 8 time with Chrony.