How to set and verify NTP on Linux

NTP is a time syncronisation protocol that uses regular polls of time servers on the internet to keep the clock of the system correct.

The configuration of ntp is done in /etc/ntp.conf.  The section you are interested in is this:

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 1.uk.pool.ntp.org
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

The servers should be set to the UK range first followed by servers farther afield.

Once this is set, restart the ntp service:

service ntpd restart[ENTER]
Redirecting to /bin/systemctl restart ntpd.service

Then check the ntpservice is running and able to reach the NTP servers:

ntpstat[ENTER]

If you get this response, NTP is working normally:

synchronised to NTP server (85.199.214.98) at stratum 2
time correct to within 11 ms
polling server every 256 s

If you get this response, NTP is unable to reach the NTP servers and it is recommended to check that the firewall is not preventing access to the NTP service on UDP port 123

timeout

  
To get more information about NTP's status, use the ntpq command:

ntpq -pn[ENTER]

This will list the NTP servers the system is sycronising with:

remote           refid st  t when poll reach delay   offset jitter
==============================================================================
*85.199.214.98   .GPS.  1  u 38    64    377 5.047  -0.184  0.131
81.21.65.168     .STEP. 16 u  -  1024      0 0.000   0.000  0.000
178.79.155.116   .STEP. 16 u  -  1024      0 0.000   0.000  0.000
81.21.76.27      .STEP. 16 u  -  1024      0 0.000   0.000  0.000

This command will give more detail on the status and enable you to confirm if the NTP daemon has ever syncronised:

ntpq -c rv[ENTER]

Amongst the output the leap status is important:


associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd 4.2.6p5@1.2349-o Fri Apr 13 12:52:27 UTC 2018 (1)",
processor="x86_64", system="Linux/3.10.0-957.21.3.el7.x86_64", leap=00,
stratum=3, precision=-23, rootdelay=53.867, rootdisp=213.802,
refid=81.21.65.169,
reftime=e37a2f11.acc7327b Tue, Dec 8 2020 16:57:53.674,
clock=e37a2f12.76ae8bde Tue, Dec 8 2020 16:57:54.463, peer=20954, tc=6,
mintc=3, offset=-2.069, frequency=23.652, sys_jitter=0.000,
clk_jitter=0.707, clk_wander=0.006

leap_none indicates normal operations while leap_alarm confirms the system has never sycronised


Finally, the timedatectl command offers a host of information about the configuration and status of the system including the time zone, NTP status, whether daylight savings is in effect and the last daylight savings change:

timedatectl status[ENTER]

Local time: Tue 2020-12-08 17:09:46 GMT
Universal time: Tue 2020-12-08 17:09:46 UTC
RTC time: Tue 2020-12-08 17:09:47
Time zone: Europe/London (GMT, +0000)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2020-10-25 01:59:59 BST
Sun 2020-10-25 01:00:00 GMT
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2021-03-28 00:59:59 GMT
Sun 2021-03-28 02:00:00 BST


Need help?  Please get in touch!

You can call us on 01752 422950, option 2 or, if you are on Number Club, just call extension 3000

You can email us at support@hellocomtec.com

You can chat with us now at https://kite.wildix.com/nc-a12/3000

 

 

Did you find this article useful?