1

I am running Ubuntu 20.04 and using timedatectl with timesyncd. If I enable NTP sync then my local and universal dates get set to the year 2058.

If I do a manual check (using python) the NTP servers I am using are working correctly. This has happened before and somehow corrected itself but is now happening again.

Any idea what is going wrong?

               Local time: mié 2058-05-22 01:16:55 CEST
           Universal time: mar 2058-05-21 23:16:55 UTC 
                 RTC time: sáb 2022-05-21 22:21:03     
                Time zone: Europe/Madrid (CEST, +0200) 
System clock synchronized: no                          
              NTP service: active                      
          RTC in local TZ: no      

/etc/systemd/timesyncd.conf

[Time]
NTP=pool.ntp.org ntp.ubuntu.com
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048

1 Answers1

1

I managed to find the issue and resolve it. Posting it here for anyone who has the same issue.

I first checked the logs for systemd-timesyncd and found that connecting to the ntp server was timing out and the date/time was being set to the last recorded timestamp.

> systemctl status systemd-timesyncd
may 22 00:31:38 falcon systemd[1]: Starting Network Time Synchronization...
may 22 00:31:38 falcon systemd-timesyncd[73828]: System clock time unset or jumped backwards, restoring from recorded timestamp: Wed 2058-05-22 01:16:53 CEST
may 22 01:16:53 falcon systemd[1]: Started Network Time Synchronization.
may 22 01:17:04 falcon systemd-timesyncd[73828]: Timed out waiting for reply from 91.189.91.157:123 (ntp.ubuntu.com).

I tried to fetch the time from the ntp server using python and saw that it was failing with the time set so far ahead. Manually fixing the time allowed the current time to be fetched. This meant that I could not connect to the ntp server because my date/time was being set to the recorded timestamps year 2058 which then prevent further syncs.

import ntplib
from time import ctime
c = ntplib.NTPClient()
response = c.request('ntp.ubuntu.com')
print(ctime(response.tx_time))

I then checked the docs for timesyncd and found that the recorded time is saved in /var/lib/systemd/timesync/clock as the last modified time.

So I reset this files modified and last accessed dates.

touch -a -m -t 202205212221 /var/lib/systemd/timesync/clock

I then disabled ntp and manually set the time followed by restarting timesyncd and all is now working.