When setting the date in Debian 8 it reverts to the current time after a few seconds. How to actually manually set date and time in Debian 8? NTP is not running.

+ set -x
+ sudo timedatectl set-time 2000-01-01
+ timedatectl
      Local time: Sat 2000-01-01 00:00:00 CET
  Universal time: Fri 1999-12-31 23:00:00 UTC
        RTC time: Fri 1999-12-31 23:00:00
       Time zone: Europe/Vienna (CET, +0100)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 1999-10-31 02:59:59 CEST
                  Sun 1999-10-31 02:00:00 CET
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2000-03-26 01:59:59 CET
                  Sun 2000-03-26 03:00:00 CEST
+ date
Sat Jan  1 00:00:00 CET 2000
+ sleep 10
+ date
Fri Sep  7 23:14:18 CEST 2018
  • 1
    Do you have ntp running? – Wildcard Sep 7 '18 at 21:19
  • 1
    Actually, do you have ntpd or chrony running? – Rui F Ribeiro Sep 7 '18 at 21:47
  • Should have mentioned that: ntp is not running, of course. – astifter Sep 7 '18 at 21:47
  • Not sure whether systemd-resolve is already in Debian 8....you might have NTP. What virtualization environment is that? – Rui F Ribeiro Sep 7 '18 at 21:48
  • VirtualBox on a Win7 host, vbox- installed. – astifter Sep 7 '18 at 21:52

Typically VMs can and get synchronised on time by the virtualisation hypervisors (depending on configuration and virtualisation technology and having the tools installed)

Your VM is getting the time synchronised by the Virtualbox Hypervisor.

So to keep getting the time adjusted to the time of your virtualisation host, you have to disable that synchronisation.

You can disable temporarily it in the command line as in:

VBoxManage setextradata "VMname" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

Where VMName is the name of your VM as known by VirtualBox.

It will stop the time synchronisation while you do not restart the VM.

For doing this setting permanently, you have to stop that VM, edit yourVMname.vbox and add this entry to the section:

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

Jessie is also a distribution that comes by default with systemd, and for those using systemd, systemd-timesyncd comes enabled by default.

systemd-timesyncd also keeps your time current. You also need to stop/disable it.

You can stop it temporarily with:

sudo service systemd-timesyncd stop

More recently, the Debian maintainers of the VirtualBox Guest Utilities have made the guest utilities service conflict with systemd-timesyncd.service so that systemd will simply not run the latter if the Guest Utilities are run. Debian people would like the same for the chrony and ntpd services, too.

  • 1
    Took me a while to make sure this works and yes, it does. Thanks! – astifter Sep 23 '18 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.