ntp – How Does Timedatectl Sync Time Without NTP on CentOS 7?

ntptime-synchronization

I am creating automated tests for an rsync-like utility and I need to be able to set the clock back 24 hours for one of the tests. However, when I use timedatectl to set the time and date they revert back to the current time after 15 seconds.

Checking timedatectl status I see that it is not running NTP:

# timedatectl status
      Local time: Wed 2019-05-15 23:24:17 EDT
  Universal time: Thu 2019-05-16 03:24:17 UTC
        RTC time: Wed 2019-01-16 02:13:40
       Time zone: America/New_York (EDT, -0400)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2019-03-10 01:59:59 EST
                  Sun 2019-03-10 03:00:00 EDT
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2019-11-03 01:59:59 EDT
                  Sun 2019-11-03 01:00:00 EST

I also checked and NTPD is not running and nothing is bound to port 123.

Does timedatectl have another method of syncing time? The CentOS 7 test machine is running in a Docker container under a VirtualBox image so Internet connectivity is somewhat limited. I am also testing on CentOS directly on VirtualBox so I will need to solve for the non-Docker case as well.

Best Answer

VBox Guest Additions includes and enables time syncronisation with the host by default.

You can disable this with the following command:

vboxmanage setextradata <vmname> "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Or add the following line to your yourVM.vbox file

<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" value="1"/>
Related Topic