How To Verify Ntp Setup Is Working Properly In Linux Or UNIX Server?

Photo of author

By rasho

Earlier I worte an article about installing NTP (Network Time Protocol) on your linux box. This article is all about verifying that your NTP setup is working properly. Normally I use some monitoring tool like nagios to monitor NTP status and alert me if time on my server goes out of sync. However, if you wish to do it manually here are the command.

There are two commands that can help you find ntp current state quickly and reliably.

ntpq – standard NTP query program
ntpstat – show network time synchronisation status

Lets run it on an unsynced box and see what happens. I have just installed ntpd on this server, initially it will take a min or two to sink to the peer server. So just after the installation the output will look like this. Please note that this is the same state which you will find in case your ntp daemon has stopped working or is not working properly.

# ntpstat

unsynchronised
time server re-starting
polling server every 64 s

# ntpq -c peers

remote refid st t when poll reach delay offset jitter
======================================================================
hamilton-nat.nu .INIT. 16 u - 64 0 0.000 0.000 0.001
ns2.telecom.lt .INIT. 16 u - 64 0 0.000 0.000 0.001
fidji.daupheus. .INIT. 16 u - 64 0 0.000 0.000 0.001

The third column st stands for stratum.

The lower the number, the closer your box is to the time source.
If the Stratum is 16, it normally indicates that your linux server could not reach any of the time peers defined in your ntp.conf file and thus is not synchronized.

If you see a star (*) against the name of a time server, your time is being synchronised properly. The output shown above is for an unsynchronized machine, below one shows a synced machine.

# ntpq -c peers or ntpq -p
remote refid st t when poll reach delay offset jitter
=====================================================================
+hamilton-nat.nu 10.220.3.5 2 u 57 64 377 184.987 -81.848 42.169
*ns2.telecom.lt 212.59.3.3 2 u 49 64 377 234.048 -92.309 43.699
+fidji.daupheus. 88.191.80.53 3 u 57 64 377 171.628 -85.398 39.625

If you so wish you can force a sync manually, when you have installed ntp and do not wish to wait for the time it takes to sync or your ntp has gone out of sync, use ntpdate.

yum install ntpdate
/etc/init.d/ntp stop
ntpdate -u 10.220.3.5
/etc/init.d/ntp start

 

Leave a Comment