1

the time-synchronization does not work on my Ubuntu 20.04 (it always shows a time two hours ahead of the actual time). I have tried to follow the hints here and here but without success.

I have already installed ntp, but when I run

timedatectl set-ntp on

in the terminal I get the output:

Failed to set ntp: NTP not supported

It drives me crazy because even when I set the time manually, it reverts to the old (and wrong) setting after restart.

Any hint is greatly appreciated!

Artur Meinild
  • 21,605
  • 21
  • 56
  • 89
Philipp
  • 11
  • 1
  • 2
  • You have possibly selected wrong time zone. Is this a desktop or a server system? Please, remove `ntp` and [edit] your question by adding the output of `systemctl status systemd-timesyncd`. – FedKad Jul 13 '22 at 16:06
  • Are you dual booting or is Ubuntu the only installed OS? – Nmath Jul 13 '22 at 18:15

1 Answers1

2

You have probably selected wrong time zone.

Also, if the system is not going to be used as a time server, the ntp daemon is not recommended in recent versions of Ubuntu. Instead, systemd-timesyncd daemon should be used.

Please,

  1. Run sudo apt remove ntp to remove ntp.

  2. Run sudo apt install --reinstall systemd-timesyncd to refresh systemd-timesyncds installation.

  3. Run sudo dpkg-reconfigure tzdata to select the correct time zone.

  4. Afterwards, run cat /etc/timezone to check it.

  5. Run, timedatectl status to check that:

    System clock synchronized: yes
                  NTP service: active
              RTC in local TZ: no
    

    Note: If you are not dual booting (with Windows) you should set the hardware clock to UTC (i.e., RTC in local TZ: no in the above output), using the command timedatectl set-local-rtc 0 --adjust-system-clock. For more information see this: How to tell Ubuntu that hardware clock is local time?

  6. Run, systemctl status systemd-timesyncd to check that systemd-timesyncd daemon is:

    Active: active (running) since ...
    
  7. If it is not active, run systemctl enable systemd-timesyncd to enable it and systemctl restart systemd-timesyncd to start it.

  8. If you get errors in the above commands, you may need to run:

    $ timedatectl set-ntp false
    $ ## set approximate time manually using the `date` command.
    $ timedatectl set-ntp true
    

    and retry from step 5.

  9. Reboot system and check once more.

Zanna
  • 69,223
  • 56
  • 216
  • 327
FedKad
  • 9,212
  • 7
  • 40
  • 79
  • 2
    removing `systemd-timesyncd` uninstalls hundreds of packages that depend on it, according to `apt -s remove` on my system. Such drastic changes are very unlikely to be reversible. I am going to edit your answer to use the handy `--reinstall` flag instead. – Zanna Aug 03 '23 at 11:49
  • Good catch @Zanna – Artur Meinild Aug 03 '23 at 11:54