Time sync on Ubuntu 18.04

I will give an example of setting time synchronization on Ubuntu Server 18.04.

In Ubuntu 18, the systemd-timesyncd service is enabled by default and time synchronization reports can be seen in the /var/log/syslog file, for example:

systemd-timesyncd[979]: Synchronized to time server 91.189.89.198:123 (ntp.ubuntu.com)

In the configuration file /etc/systemd/timesyncd.conf, you can see the standard values for some parameters that can be uncommented and changed:

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

For example, in order to synchronize time approximately once a day:

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

Restart systemd-timesyncd to apply the changes:

systemctl restart systemd-timesyncd.service
systemctl status systemd-timesyncd.service

Let’s see the current time settings:

timedatectl
date

I have displayed:

                      Local time: Mon 2020-07-13 22:07:45 EEST
                  Universal time: Mon 2020-07-13 19:07:45 UTC
                        RTC time: Mon 2020-07-13 19:07:45
                       Time zone: Etc/UTC (EEST, +0300)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

To disable time synchronization, you can do:

timedatectl set-ntp off

Check the status of the service (should not be started and disabled):

systemctl status systemd-timesyncd.service
systemctl is-enabled systemd-timesyncd.service

If necessary, you can turn it back on:

timedatectl set-ntp on

Example time zone changes:

timedatectl list-timezones
timedatectl list-timezones | grep -i europe
timedatectl set-timezone Europe/Kiev

Example of manual time setting:

timedatectl set-time 2020-07-14 11:08:00

See also my article:
Configuring NTP Client and NTP Server in Linux

Leave a comment

Leave a Reply