1

I'm setting the system clock using the following command:

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

Immediately after executing I run just date and see that the date and time is December 31 2015. Then, after waiting about three seconds, I run date again and see that it has changed back to today's date.

Why is it syncing again to the current date and how can I stop it?

[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

All my currently running services:

[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...

2 Answers2

2

It's because your machine is a VirtualBox virtual machine, and

The VirtualBox Additions are currently running.

By default VirtualBox guests will sync their time to the host. If you want to change this behavior, see the documentation.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • I go have dinner and Michael steals my thunder. Indeed, VB will be supplying its own internal clock updating mechanism. – JayMcTee Jan 04 '16 at 18:17
  • I tried that. Syncing seeming to slow down from 3 seconds to about 10 seconds, but it does still resync the time. – The Unknown Dev Jan 04 '16 at 18:36
  • @Jamil What is the "that" that you tried? – Michael Hampton Jan 04 '16 at 18:39
  • @MichaelHampton I tried the command listed under "Disabling the Guest Additions time synchronization" in the link you provided. In the end, to get it work, I had to stop `/etc/init.d/vbox-service` in the VM. After that, the time stopped syncing. – The Unknown Dev Jan 04 '16 at 18:43
0

You most likely have NTP (Network TIme Protocol) enabled and in sync mode. See my output for the timedatectl command:

$ 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

Note in particular:

     NTP enabled: yes
NTP synchronized: yes

You can use timedatectl to then disable the syncing:

$ timedatectl set-ntp false

JayMcTee
  • 3,923
  • 1
  • 13
  • 22