How to verify ntp service properly or not in linux/unix

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值