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,836
  • 2
  • 18
  • 24
  • Please show the output of `timedatectl status`. You're doing some strange things, like setting your system time from the hardware clock (`sudo hwclock --systohc`). – Artur Meinild Oct 17 '22 at 10:20
  • Also, did you follow the advice from [your own previous question](https://askubuntu.com/questions/1314479/ntp-not-supported), to get timesync to work this time? – Artur Meinild Oct 17 '22 at 10:35
  • Please see the updated post with current times. – mahmood Oct 17 '22 at 10:57
  • @ArturMeinild: Using `sudo timedatectl set-ntp yes`, you can see the setting `NTP service: active`. – mahmood Oct 17 '22 at 10:58
  • Did you install `ntpd` or `chrony`? If you did so, you should explicitly state so, since Ubuntu uses `timesyncd` by default. – Artur Meinild Oct 18 '22 at 13:13
  • Please see the updated post. – mahmood Oct 18 '22 at 13:29
  • Ok this clears up some things. You have a few options: 1) Find out why `chrony` isn't syncing correctly or 2) Remove both `ntp` and `chrony`, and revert to `systemd-timesyncd`. I can help you with 2 but not with 1. – Artur Meinild Oct 18 '22 at 14:03

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
  • 21,605
  • 21
  • 56
  • 89
  • The output of service restart is `Failed to restart systemd-timesyncd.service: Unit systemd-timesyncd.service is masked`. Also please see the updated post. – mahmood Oct 18 '22 at 13:05
  • Did you follow the advice from [your own previous question](https://askubuntu.com/a/1317803/1066942) to unmask the service? – Artur Meinild Oct 18 '22 at 13:12
  • chronyd is running while ntp is masked and inactive. – mahmood Oct 18 '22 at 13:26