dt.iki.fi

Time not synced

I noticed that my server's (Debian stable) datetime was way off. Years. Strange, because I was sure I had enabled systemd-timesyncd (but apparently never gave it a second thought after that).

Looking at systemctl status systemd-timesyncd I found this cryptic message:

● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at ....(datetime)....; 1s ago
           ConditionFileIsExecutable=!/usr/sbin/ntpd was not met
     Docs: man:systemd-timesyncd.service(8)

Yes, ntp is installed, and /usr/sbin/ntpd exists.

Apparently systemd-timesyncd will only start when ntpd is not installed.

Additionally, my system got very confused by the wrong date (the CMOS battery is probably completely shot), and I had to manually set it before i could do anything else... anyhow, this fixed it:

#> date -s '2021-04-24 20:09' # or whatever your current datetime is
#> apt purge ntp
#> systemctl restart systemd-timesyncd

I suspect that this somehow broke during the last dist-upgrade, or maybe during some systemd upgrade. In any case, the reason ntp was (still) installed probably goes back many years (This install went through at least two stable-to-stable dist-upgrades).