Score:2

Wrong system time when NTP is enabled?

pl flag

I am running Ubuntu 20.04 on my laptop. Ever since the installation I have never had any problems with the date/time going out of sync.

But today when I started the laptop the system time was completely wrong. I can disable NTP and set the correct time manually but the moment I re-enable NTP the time jumps back to being wrong:

david@david-XPS-15-9570  ~  timedatectl 
               Local time: Mo 2021-10-04 08:20:36 CEST
           Universal time: Mo 2021-10-04 06:20:36 UTC 
                 RTC time: Mo 2021-10-04 06:20:37     
                Time zone: Europe/Vienna (CEST, +0200)
System clock synchronized: no                         
              NTP service: inactive                   
          RTC in local TZ: no                         
 david@david-XPS-15-9570  ~  sudo timedatectl set-ntp on
 david@david-XPS-15-9570  ~  timedatectl                
               Local time: Mo 2038-10-04 07:52:04 CEST
           Universal time: Mo 2038-10-04 05:52:04 UTC 
                 RTC time: Mo 2021-10-04 06:21:14     
                Time zone: Europe/Vienna (CEST, +0200)
System clock synchronized: no                         
              NTP service: active                     
          RTC in local TZ: no                         
  • I have rebooted the laptop multiple times, just to be sure
  • I checked the date and time in the BIOS - they are correct

Any idea what's going on here?

ADDITIONAL INFO:

AFAICT, NTP should be querying ntp.ubuntu.com

david@david-XPS-15-9570  ~  cat /etc/systemd/timesyncd.conf 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See timesyncd.conf(5) for details.

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

... which, according to https://servertest.online/ntp should be fine...

MORE ADDITIONAL INFO:

david@david-XPS-15-9570  ~  service chronyd status              
Unit chronyd.service could not be found.
david@david-XPS-15-9570  ~  service systemd-timedated status
● systemd-timedated.service - Time & Date Service
     Loaded: loaded (/lib/systemd/system/systemd-timedated.service; static; vendor preset: enabled)
     Active: active (running) since Mon 2021-10-04 14:47:02 CEST; 14s ago
       Docs: man:systemd-timedated.service(8)
             man:localtime(5)
             https://www.freedesktop.org/wiki/Software/systemd/timedated
   Main PID: 9393 (systemd-timedat)
      Tasks: 1 (limit: 38042)
     Memory: 1.3M
     CGroup: /system.slice/systemd-timedated.service
             └─9393 /lib/systemd/systemd-timedated

Okt 04 14:47:02 david-XPS-15-9570 systemd[1]: Starting Time & Date Service...
Okt 04 14:47:02 david-XPS-15-9570 systemd[1]: Started Time & Date Service.
 david@david-XPS-15-9570  ~  sudo timedatectl set-ntp on         
 david@david-XPS-15-9570  ~  service systemd-timedated status
● systemd-timedated.service - Time & Date Service
     Loaded: loaded (/lib/systemd/system/systemd-timedated.service; static; vendor preset: enabled)
     Active: active (running) since Mon 2021-10-04 14:47:02 CEST; 16 years 11 months ago
       Docs: man:systemd-timedated.service(8)
             man:localtime(5)
             https://www.freedesktop.org/wiki/Software/systemd/timedated
   Main PID: 9393 (systemd-timedat)
      Tasks: 1 (limit: 38042)
     Memory: 1.4M
     CGroup: /system.slice/systemd-timedated.service
             └─9393 /lib/systemd/systemd-timedated

Okt 04 14:47:02 david-XPS-15-9570 systemd[1]: Starting Time & Date Service...
Okt 04 14:47:02 david-XPS-15-9570 systemd[1]: Started Time & Date Service.
Okt 04 14:47:25 david-XPS-15-9570 systemd-timedated[9393]: systemd-timesyncd.service: Enabling unit.
Okt 04 14:47:25 david-XPS-15-9570 systemd-timedated[9393]: Set NTP to enabled (systemd-timesyncd.service).
Okt 04 07:52:02 david-XPS-15-9570 systemd-timedated[9393]: Set NTP to enabled (systemd-timesyncd.service).
 david@david-XPS-15-9570  ~  timedatectl                         
               Local time: Mo 2038-10-04 07:52:18 CEST
           Universal time: Mo 2038-10-04 05:52:18 UTC 
                 RTC time: Mo 2021-10-04 12:47:42     
                Time zone: Europe/Vienna (CEST, +0200)
System clock synchronized: no                         
              NTP service: active                     
          RTC in local TZ: no  

I changed the line in the config file to these values

NTP=pool.ntp.org
NTP=pool.ntp.org
NTP=ntp.ubuntu.com

but none made any difference...

Artur Meinild avatar
vn flag
Well, for starters your `NTP` and `FallbackNTP` lines are commented out (`#`), so it's not really clear which NTP servers are used? Also, `ntp.ubuntu.com` is under `FallbackNTP`. So try setting your preferred server under `NTP` and uncomment (remove the `#`). Also, try other NTP servers, just to test.
Wayne Vosberg avatar
bd flag
Also check `service systemd-timedated status` and `service chronyd status`
pl flag
Thank you both for your comments! @ArturMeinild - How embarrassing! I did indeed overlook the `#`s. I noticed that only the `FallbackNTP` is configured, but since I've never touched that file I thought it should work anyway... @WayneVosberg - I'll check the status and then update my question!
pl flag
@ArturMeinild - is there a way to actively check which NTP URL is being used?
Wayne Vosberg avatar
bd flag
Sorry - I use chronyd on a 21.04 system. 20.04 used systemd-timesyncd by default, so can you add the output of `service systemd-timesyncd status` ? You should see a line like: `systemd-timesyncd[1015]: Initial synchronization to time server 91.189.94.4:123 (ntp.ubuntu.com).`
Artur Meinild avatar
vn flag
Check this answer and see if it works for you: [How to sync the time to network with timedatectl on Ubuntu 18.04?](https://askubuntu.com/questions/1058593/how-to-sync-the-time-to-network-with-timedatectl-on-ubuntu-18-04)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.