How to verify ntp service properly or not in linux/unix
2013-07-13 21:50
756 查看
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
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
相关文章推荐
- Linux / Unix Script: Simple Process Checker To Find Out If A Service Is Running or Not
- How to replace # or Not assigned with blank in WAD
- How to set JAVA environment variables in Linux or CentOS
- How to reimplement (or wrap) a syscall function in linux?
- how to run 2 or more commands in a shell script [for Linux & Windows]
- How to Use Rsync to Sync New or Changed/Modified Files in Linux
- How to read Mac .DMG file in Linux or PC
- How to solve "one or more projects in the solution were not loaded correctly" problem?
- Howto Reboot or halt Linux system in emergency (ZT)
- How to properly use relative or absolute imports in Python modules? - Stack Overflow
- How to read Mac .DMG file in Linux or PC(II)
- How to create simple web service in VS2010, NOT WCF service
- How do I configure vncserver to start GNOME or KDE by default in Red Hat Enterprise Linux ?
- How to fix the issue that GEM_HOME and/or GEM_PATH not set issue for rvm in mac version 10.12
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- Resolving www.linuxde.net... failed: Name or service not known. wget: unable to resolve host address
- win server 2003下IIS无法启动,报错:The service did not respond to the start or control request in a timely fashion.
- IIS Default Web Site : The service did not response to the start or control request in a timely fashion
- The MSSQL Reporting Services (SSRS) service failed to start : The service did not respond to the start or control request in a timely fashion
- How to deal with "Could not find component on update server. Contact VMware Support or your system administrator." in Vmware.