在哪里可以看到 ntpd 工作状态(日志或消息)

aun*_*low 1 ntp ntpd ntpdate

在我的服务器中,ntpd 服务已启动,但似乎不起作用。

我找不到任何根据这个(ntpd日志文件位于哪里,以及我们如何配置ntpd日志文件路径?)和这个(在哪里可以查找ntpd日志?):-(

根据MadHatter的建议(请参阅如何持续与NTP服务器同步系统时间?),我列出了我的服务器中的一些信息:

ntpdate返回:

2 May 21:47:55 ntpdate[47274]: the NTP socket is in use, exiting
Run Code Online (Sandbox Code Playgroud)

ntpq -c as返回:

ind assID status  conf reach auth condition  last_event cnt
===========================================================
  1 22393  9614   yes   yes  none  sys.peer   reachable  1
  2 22394  9414   yes   yes  none  candidat   reachable  1
  3 22395  9414   yes   yes  none  candidat   reachable  1
Run Code Online (Sandbox Code Playgroud)

ntpq -c pe返回:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*time5.aliyun.co 10.137.38.86     2 u  157 1024  377   42.869    3.156   0.274
+time7.aliyun.co 10.137.38.86     2 u  402 1024  377   42.997    4.893   0.251
+ntp3.aliyun.com 10.137.38.86     2 u  276 1024  377   38.393    7.159   0.263
Run Code Online (Sandbox Code Playgroud)

我的ntp.conf(# 行未列出)是:

minpoll 4
maxpoll 8
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server ntp1.aliyun.com
server ntp2.aliyun.com
server ntp3.aliyun.com
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
Run Code Online (Sandbox Code Playgroud)

更新

ntpq -c rv返回:

assID=0 status=0644 leap_none, sync_ntp, 4 events, event_peer/strat_chg,
version="ntpd 4.2.4p8@1.1612-o Tue Nov 29 00:09:12 UTC 2011 (1)",
processor="x86_64", system="Linux/2.6.32-220.4.1.el6.x86_64", leap=00,
stratum=3, precision=-20, rootdelay=42.918, rootdispersion=11.376,
peer=18777, refid=182.92.12.11,
reftime=dad1e8b1.6b42ba77  Mon, May  2 2016 22:54:41.418, poll=8,
clock=dad1e995.5771e298  Mon, May  2 2016 22:58:29.341, state=4,
offset=-0.578, frequency=23.898, jitter=1.845, noise=1.218,
stability=0.223, tai=0
Run Code Online (Sandbox Code Playgroud)

ps 该服务器位于中国成都(GMT+8)

Mad*_*ter 5

最终的声明在你的ntpq -c rv输出中,它说

stratum=3
Run Code Online (Sandbox Code Playgroud)

您已同步;工作ntpd 。当您的守护程序报告层不是 16 时,您就知道您已同步。在这种情况下,ntpq -c pe告诉您您的系统对等点(您的守护程序当前遵循其时钟的系统对等点)是time5.aliyun.com,又名ntp1.aliyun.com。它的层数是 2,而你的层数更大,这是正确的行为。

ntpdate返回套接字使用中错误,因为套接字正在使用中,并且ntpd正在运行;一旦守护进程运行,您就无法使用ntpdate来移动时钟。这就是为什么通常在启动时、守护进程启动之前ntpdate运行。