Ubuntu – Prevent clock from advancing to a system time after Ubuntu Server build time

clockdatertcservertime

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.

Best Answer

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