Linux上的ntp服务,重启后不运行

我的服务器上的时间已经正确同步了几个星期,然后我们上周重新启动服务器,今天是10分钟。 我做了“sudo ntpdate ntp.ubuntu.com”,得到:

4 Oct 14:22:08 ntpdate[17734]: the NTP socket is in use, exiting

我猜这意味着它已经在运行了……但是当我重新启动服务器时,为什么它没有运行呢?

更新

/etc/ntp.conf中

 driftfile /var/lib/ntp/ntp.drift statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable server ntp.ubuntu.com server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery restrict 127.0.0.1 restrict ::1 

你确定ntpd没有运行时,重新启动盒子? 检查你的系统日志的启动日志,看它是否在启动时启动。

此外,请记住,如果时间过多,ntpd会认为您的时间源可能存在问题,并且不会改变时间。 默认情况下,如果从外部时间服务器报告的时间与本地时间相差超过1000秒,则会发生这种情况。 这些年来我遇到了一些问题(如CMOS电池电量不足),可能会导致本地计算机在重新启动时发生大量时间偏差。

仔细检查你的/etc/ntp.confconfiguration,确保它是准确的(时间服务器可到达等)。 然后尝试重新启动ntpd,并在做这件事情时观看日志 。 看看那里一切看起来不错。 然后回到你的系统日志,find所有ntpd相关的日志。 查找错误,问题等。确保它在启动时启动。

在这种情况下,日志通常会成为您进行故障排除的最佳信息来源。

如果时间超过1000秒,并且需要重置,则需要先停止ntpd,然后运行ntpdate重置时间,然后重新启动ntpd。 以下命令将执行此操作:

 sudo /etc/init.d/ntp stop sudo ntpdate 0.north-america.pool.ntp.org sudo /etc/init.d/ntp start 

如果在每次重新引导时出现错误,那么在每次引导时启动ntpd之前,可能需要脚本化ntpdate才能运行。 这应该有助于在ntpd处理之前将时间重置为可pipe理的状态。

ntp可能正在运行,但它已经放弃了你的操作系统时钟太不可靠了。

使用该命令

 ntpq -np 

…看看ntp认为它在做什么。

虚拟机? 计时是相当困难的。

VMWare的这个文档对我的情况非常有帮助

http://www.vmware.com/files/pdf/Timekeeping-In-VirtualMachines.pdf