How to check Chronyc clock and sync our system clock ?

Today in this post, we will see how to check chrony status on our system and sync our clock in case its not synced.

Lets look step by step how to do this.

1. Check chronyd service and its log visible in service status.

[root@ngelinux001 ~]# service chronyd status
Redirecting to /bin/systemctl status chronyd.service
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2022-08-24 08:39:51 EDT; 2 days ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 1454347 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 1454342 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 1454345 (chronyd)
    Tasks: 1 (limit: 101096)
   Memory: 360.0K
   CGroup: /system.slice/chronyd.service
           └─1454345 /usr/sbin/chronyd

Aug 24 08:39:51 ngelinux001 systemd[1]: Starting NTP client/server...
Aug 24 08:39:51 ngelinux001 chronyd[1454345]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +>
Aug 24 08:39:51 ngelinux001 chronyd[1454345]: Frequency -36.476 +/- 0.900 ppm read from /var/lib/chrony/drift
Aug 24 08:39:51 ngelinux001 chronyd[1454345]: Using right/UTC timezone to obtain leap second data
Aug 24 08:39:51 ngelinux001 systemd[1]: Started NTP client/server.
Aug 24 08:42:01 ngelinux001 chronyd[1454345]: Selected source 139.99.240.5
Aug 24 08:42:01 ngelinux001 chronyd[1454345]: System clock TAI offset set to 37 seconds
Aug 24 08:42:01 ngelinux001 chronyd[1454345]: System clock wrong by -2.848067 seconds, adjustment started
Aug 24 08:41:58 ngelinux001 chronyd[1454345]: System clock was stepped by -2.848067 seconds

2. Check the server from which the clock gets synced.

[root@ngelinux001 ~]# tail /etc/chrony.conf

# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking
server ntp-ngeindia.ngelinux.com
[root@ngelinux001 ~]#

 

3. Sync the clock from server.

[root@ngelinux001 ~]# chronyd -q 'server ntp-ngeindia.ngelinux.com iburst'
2022-08-24T11:35:13Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
2022-08-24T11:35:13Z Fatal error : Another chronyd may already be running (pid=1071), check /var/run/chrony/chronyd.pid
[root@ngelinux001 ~]#

### Check out the PID
[root@ngelinux001 ~]# cat /var/run/chrony/chronyd.pid
1071

### Check the process ID
[root@ngelinux001 ~]# ps -ef | grep -i 1071
chrony      1071       1  0 Aug18 ?        00:00:00 /usr/sbin/chronyd
root     1440367 1436528  0 07:36 pts/3    00:00:00 grep --color=auto -i 1071
[root@ngelinux001 ~]#

 

4. Check out the clock sync tracking.

[root@ngelinux001 ~]# chronyc tracking
Reference ID    : 8B63F005 (ntp_server.ngelinux.com)
Stratum         : 9
Ref time (UTC)  : Wed Aug 24 11:26:00 2022
System time     : 0.000152016 seconds slow of NTP time
Last offset     : -0.000289631 seconds
RMS offset      : 0.000226364 seconds
Frequency       : 36.101 ppm slow
Residual freq   : -0.005 ppm
Skew            : 0.089 ppm
Root delay      : 0.075418741 seconds
Root dispersion : 0.004744601 seconds
Update interval : 1029.2 seconds
Leap status     : Normal
[root@ngelinux001 ~]#

 

5. Verify the sources/server.

[root@ngelinux001 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp_server.ngelinux.com       8  10   377   731  -1308us[-1597us] +/-   42ms
[root@ngelinux001 ~]#

### Verify the source stats
[root@ngelinux001 ~]# chronyc sourcestats -v
210 Number of sources = 1
                             .- 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
==============================================================================
ntp_server.ngelinux.com    21  13  362m     -0.005      0.080  -4150ns   630us
[root@ngelinux001 ~]#

Hope this is useful, and now you can identify if the clock is synced or not and sync it to the server is there is offset.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments