How to verify my NTP working or not?
Posted: Mon May 09, 2016 4:56 pm
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:
Sample outputs:
synchronised to NTP server (149.20.54.20) at stratum 3
Use the echo command to display exit status of ntp client:
Sample outputs:
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
OR
The above is an example of working ntp client. Where,
-p : Print a list of the peers known to the server as well as a summary of their state.
-n : Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.
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.
Code: Select all
$ ntpstat
synchronised to NTP server (149.20.54.20) at stratum 3
Code: Select all
time correct to within 42 ms
polling server every 1024 s
Code: Select all
$ echo $?
Code: Select all
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
Code: Select all
cahtoh02:/root%ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
+204.2.134.163 44.24.199.34 3 u 614 1024 377 58.701 -0.559 9.248
216.152.240.220 216.218.254.202 2 u 72h 1024 0 10.667 1.934 0.000
*209.208.79.69 130.207.244.240 2 u 479 1024 377 71.919 5.643 3.746
Code: Select all
cahtoh02:/root%ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+pacific.latt.ne 44.24.199.34 3 u 625 1024 377 58.701 -0.559 9.248
216.152.240.220 216.218.254.202 2 u 72h 1024 0 10.667 1.934 0.000
*209.208.79.69 130.207.244.240 2 u 492 1024 377 71.919 5.643 3.746
-p : Print a list of the peers known to the server as well as a summary of their state.
-n : Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.