系统时钟在设置之后总是重新同步

我正在使用以下命令设置系统时钟:

date -s "31 DEC 2015 12:00:00"

执行后立即运行date ,看到date和时间是2015年12月31日。然后,等待大约三秒钟后,我再次运行date ,看到它已经改变回到今天的date。

为什么它再次同步到当前date,我该如何阻止它?

 [root@localhost mm]# date -s "31 DEC 2015 12:00:00" Thu Dec 31 12:00:00 EST 2015 [root@localhost mm]# date Thu Dec 31 12:00:02 EST 2015 [root@localhost mm]# date Thu Dec 31 12:00:03 EST 2015 [root@localhost mm]# date Mon Jan 4 11:53:17 EST 2016 

我所有正在运行的服务:

 [root@localhost mm]# service --status-all atd (pid 2317) is running... auditd (pid 1464) is running... consul (pid 2332) is running... crond (pid 2212) is running... cupsd (pid 1562) is running... dnsmasq is stopped elasticsearch (pid 4046) is running... service firstboot supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add firstboot') firstboot is not scheduled to run hald (pid 1604) is running... htcacheclean is stopped httpd (pid 7537) is running... ip6tables: Firewall is not running. iptables: Firewall is not running. iscsi is stopped iscsid is stopped Checking jexec statuslvmetad is stopped dmeventd is stopped mdmonitor is stopped memcached (pid 2181) is running... messagebus (pid 1527) is running... mongod (pid 2293) is running... multipathd is stopped mysqld (pid 2067) is running... netconsole module not loaded Configured devices: lo eth0 eth1 Currently active devices: lo eth0 eth1 NetworkManager (pid 1540) is running... ntpd is stopped portreserve is stopped master dead but pid file exists pppoe-server is stopped rdisc is stopped rsyslogd (pid 1498) is running... sandbox is stopped saslauthd is stopped sendmail (pid 2288) is running... sm-client (pid 2289) is running... spice-vdagentd is stopped openssh-daemon (pid 1811) is running... The VirtualBox Additions are currently running. Checking for VBoxService ...running wdaemon is stopped winbindd is stopped wpa_supplicant (pid 1603) is running... 

这是因为你的机器是一个VirtualBox虚拟机,而且

 The VirtualBox Additions are currently running. 

默认情况下,VirtualBox的客人将同步他们的时间到主机。 如果您想要更改此行为 ,请参阅文档。

您最有可能已启用NTP(networkingTIme协议)并处于同步模式。 看到我的输出timedatectl命令:

 $ timedatectl Local time: Mon 2016-01-04 18:06:04 CET Universal time: Mon 2016-01-04 17:06:04 UTC Timezone: Europe/Amsterdam (CET, +0100) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: no Last DST change: DST ended at Sun 2015-10-25 02:59:59 CEST Sun 2015-10-25 02:00:00 CET Next DST change: DST begins (the clock jumps one hour forward) at Sun 2016-03-27 01:59:59 CET Sun 2016-03-27 03:00:00 CEST 

特别注意:

  NTP enabled: yes NTP synchronized: yes 

您可以使用timedatectl来禁用同步:

$ timedatectl set-ntp false