timesyncd.conf

Network Time Synchronization

Network Time Synchronization configuration files

/etc/systemd/timesyncd.conf
/etc/systemd/timesyncd.conf.d/*.conf
/run/systemd/timesyncd.conf.d/*.conf
/usr/lib/systemd/timesyncd.conf.d/*.conf
NFS as of 2/4/19 on raspberry pi

Control NTP network time synchronization. (small client-only NTP implementation)


As usual this page has been tersified by ed, see the man page for exact details and additional information.

/etc/systemd/ contains commented out entries showing the defaults.

[Time]
#NTP=
#FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org

If multiple files specify the same option, last occurance takes precedence.

[Time] section:

NTP=host host2 … combined with per-interface NTP servers from systemd-networkd.service from DHCP.
systemd-timesyncd will contact all configured system or per-interface servers in turn until one is found that responds. Defaults to an empty list.
FallbackNTP=host host2 … only used if no other NTP server information is known.

systemd-timesyncd.service

/lib/systemd/systemd-timesyncd synchronizes the local clock with a remote Network Time Protocol server.
Also saves the local time when the clock has been synchronized and to advance the system realtime clock on reboots to ensure it monotonically advances if the system lacks a RTC

received over DHCP. See systemd.network(5) for more details.

timedatectl set-ntp controls this service.

timedatectl

Query or change system time and date settings.

  -h --help               
     --version             
     --no-pager             Do not pipe output into a pager (See lsit-timezones)
     --no-ask-password   
  -H --host=[USER@]HOST    Operate on 
  -M --machine=container      Operate on local container
    --adjust-system-clock
           If set-local-rtc is invoked and this option is passed, the system clock is synchronized from the RTC again, taking the new
           setting into account. Otherwise, the RTC is synchronized from the system clock.

status Show current time settings
set-time time ccyy-mm-dd hh:mm:ss
set-timezone zone
list-timezones Show known time zones (there are 425 of them as of 2/4/19_
set-local-rtc bool 0 RTC in universal time; 1 local (avoid)
synchronize the RTC from the system clock.
Updates /etc/adjtime
set-ntp bool Enable or disable network time synchronization
from raspberry pi
timedatectl
Local time: Mon 2019-02-04 20:37:27 EST
Universal time: Tue 2019-02-05 01:37:27 UTC
RTC time: n/a
Time zone: America/New_York (EST, -0500)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

systemctl status systemd-timesyncd.service
* systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
`-disable-with-time-daemon.conf
Active: active (running) since Mon 2019-02-04 18:41:07 EST;or there about!! 2h 13min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 199 (systemd-timesyn)
Status: "Synchronized to time server 172.98.193.44:123 (2.debian.pool.ntp.org)."
CGroup: /system.slice/systemd-timesyncd.service
`-199 /lib/systemd/systemd-timesyncd

Feb 04 18:17:09 pi93graf systemd[1]: Starting Network Time Synchronization...
From /var/log/cron.log:
Feb 04 18:17:10 pi93graf systemd-timesyncd[199]: System clock time unset or jumped backwards,
                                        restoring from recorded timestamp: Mon 2019-02-04 18:41:07 EST

Feb 04 18:41:07 pi93graf systemd[1]: Started Network Time Synchronization.
This explains the entries in syslog
Feb 04 19:46:42 pi93graf systemd-timesyncd[199]: Synchronized to time server 172.98.193.44:123 (2.debian.pool.ntp.org).
Warning: systemd-timesyncd.service changed on disk. Run 'systemctl daemon-reload' to reload units.

https://fossies.org/linux/systemd/src/timesync/timesyncd.c shows jumped as info, should be notice or warning.

Files

/var/lib/systemd/clock the timestamp of the last successful synchronization.
ls -l /var/lib/systemd/clock
-rw-r--r-- 1 systemd-timesync systemd-timesync 0 Feb 4 20:54 /var/lib/systemd/clock it's now 21:04

cat /lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf

[Unit]
# don't run timesyncd if we have another NTP daemon installed
ConditionFileIsExecutable=!/usr/sbin/ntpd
ConditionFileIsExecutable=!/usr/sbin/openntpd
ConditionFileIsExecutable=!/usr/sbin/chronyd
ConditionFileIsExecutable=!/usr/sbin/VBoxService

See

systemd, systemd-timesyncd.service, systemd-networkd.service