HowTo: Verify My NTP Working Or Not

by on March 25, 2010 · 5 comments· LAST UPDATED February 19, 2014

in , ,

I've setup an NTP (Network Time Protocol) client and/or server to manage the system clock over a network. But, how do I verify that it is working correctly?

You can use any one of the following program to verify ntp client configuration:

  1. ntpq - standard NTP query program
  2. ntpstat - show network time synchronisation status
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsNone
Estimated completion time2m

ntpstat command

The ntpstat command will report the synchronisation state of the NTP daemon running on the local machine. If the local system is found to be synchronised to a reference time source, ntpstat will report the approximate time accuracy.

exit status

You can use the exit status (return values) to verify its operations from a shell script or command line itself:

  • exit status 0 - Clock is synchronised.
  • exit status 1 - Clock is not synchronised.
  • exit status 2 - If clock state is indeterminant, for example if ntpd is not contactable.

Type the command as follows:
$ ntpstat
Sample outputs:

synchronised to NTP server (149.20.54.20) at stratum 3
   time correct to within 42 ms
   polling server every 1024 s

Use the echo command to display exit status of ntp client:
$ echo $?
Sample outputs:

0

ntpq command

The ntpq utility program is used to monitor NTP daemon ntpd operations and determine performance. The program can be run either in interactive mode or controlled using command line arguments. Type the following command
$ ntpq -pn
OR
$ ntpq -p
Sample outputs:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*dione.cbane.org 204.123.2.5      2 u  509 1024  377   51.661   -3.343   0.279
+ns1.your-site.c 132.236.56.252   3 u  899 1024  377   48.395    2.047   1.006
+ntp.yoinks.net  129.7.1.66       2 u  930 1024  377    0.693    1.035   0.241
 LOCAL(0)        .LOCL.          10 l   45   64  377    0.000    0.000   0.001

The above is an example of working ntp client. Where,

  1. -p : Print a list of the peers known to the server as well as a summary of their state.
  2. -n : Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.

Recommend readings:

man ntpq

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 5 comments… read them below or add one }

1 Philippe Petrinko March 26, 2010 at 12:46 pm

Informative and simple. Thanks Vivek

Reply

2 Wes February 18, 2014 at 10:07 pm

You should fix this typo:

>> “exit status 1 – Cock is not synchronised.”

Reply

3 Nix Craft February 19, 2014 at 6:26 am

Thanks for the heads up. The faq has been updated.

Reply

4 Philippe Petrinko February 19, 2014 at 7:38 am
5 Nix Craft February 19, 2014 at 12:23 pm

Hi Philippe,

The post has been updated. As always, I appreciate your feedback and time :)

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: