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

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

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

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

执行后我立即运行date,看到日期和时间是 2015 年 12 月 31 日。然后,等待大约三秒钟后,我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...

答案1

这是因为你的机器是 VirtualBox 虚拟机,并且

The VirtualBox Additions are currently running.

默认情况下,VirtualBox 客户端会将其时间同步到主机。如果您想要改变这种行为,请参阅文档。

答案2

您很可能已启用 NTP(网络时间协议)并处于同步模式。请参阅我的 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 设置 ntp false

相关内容