4

I have an Ubuntu Server 18.04.1 LTS in a lab environment where I need to set the date a couple of years back in time (e.g. 2016-04-22). I can set the older date/time without any issues but the OS always resets the date/time to 2018-01-28 15:58 whenever I power the server back on. How can I prevent this?

I found a log message in /var/log/syslog indicating that the OS is switching to the previous build time: systemd[1]: System time before build time, advancing clock.

2 Answers2

2

On Ubuntu 22 I've found a way to get around this from reading the systemd-timesyncd man page where it mentions 2 files that timesync uses. After disabling the timesync server as above do the following:

  1. Set your system date and time back to the date you want
  2. sudo touch /var/lib/systemd/timesync/clock
  3. sudo touch /usr/lib/clock-epoch

Now reboot and my system time stays at my original date and time prior to the system deamon build time.

sotirov
  • 4,379
ATL
  • 21
0

Try disabling the systemd-timesyncd service:

sudo systemctl disable systemd-timesyncd

You can check if the service is running using:

sudo service systemd-timesyncd status

You can stop the service manually (one time) using:

sudo service systemd-timesyncd stop