0

I don't know why the displayed time in my Ubuntu 20.04 is different from real clock. As you can see below, I have synchronized the clock and then date command shows it is 02:54:49 PM CEST, but the query time from internet shows 10:55:18 UTC. Since CEST is +2 hours ahead, the correct CEST time should be 10+2=12 AM and my watch shows this time, too.

$ sudo hwclock --systohc
$ timedatectl status
               Local time: Mon 2022-10-17 14:54:41 CEST 
           Universal time: Mon 2022-10-17 12:54:41 UTC  
                 RTC time: Mon 2022-10-17 12:54:41      
                Time zone: Europe/Brussels (CEST, +0200)
System clock synchronized: no                           
              NTP service: active                       
          RTC in local TZ: no

$ date Mon 17 Oct 2022 02:54:49 PM CEST

$ cat </dev/tcp/time.nist.gov/13

59869 22-10-17 10:55:18 21 0 0 543.3 UTC(NIST) *

$ 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

Any idea on how to fix that?

UPDATE:

On the system, chrony is running while ntp is masked.

$ dpkg -l | grep ntp
rc  ntp                                                         1:4.2.8p12+dfsg-3ubuntu4.20.04.1       amd64        Network Time Protocol daemon and utility programs
ii  ntpdate                                                     1:4.2.8p12+dfsg-3ubuntu4.20.04.1       amd64        client for setting system time from NTP servers (deprecated)
ii  sntp                                                        1:4.2.8p12+dfsg-3ubuntu4.20.04.1       amd64        Network Time Protocol - sntp client
$ dpkg -l | grep chrony
ii  chrony                                                      3.5-6ubuntu6.2                         amd64        Versatile implementation of the Network Time Protocol
$ systemctl status ntp.service
● ntp.service
     Loaded: masked (Reason: Unit ntp.service is masked.)
     Active: inactive (dead) since Mon 2022-10-17 13:04:47 CEST; 1 day 4h ago
   Main PID: 1773 (code=exited, status=0/SUCCESS)
$ systemctl status chronyd.service
● chrony.service - chrony, an NTP client/server
     Loaded: loaded (/lib/systemd/system/chrony.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-10-17 13:09:20 CEST; 1 day 4h ago

So, it seems that ntp is replaced by chrony on the system (Don't remember about that). But I don't know how to sync the chrony.

mahmood
  • 1,875

1 Answers1

1

Use these commands to get more information about current timesync status:

  • timedatectl status (compare times, sync status etc.)
  • timedatectl timesync-status (timeserver, interval, delays, stratum etc.)

Your output of timedatectl status explicitly states that the system clock is not synchronized.

Restart your timesyncd.service to force a synchronization:

sudo systemctl restart systemd-timesyncd.service

If this doesn't work, your timeserver configuration isn't valid.

If this is the case, please include the contents of /etc/systemd/timesyncd.conf to find out why it isn't working.

Artur Meinild
  • 26,018