Update the system time using systemd as a NTP client.
Debian is by default using 0.debian.pool.ntp.org … 3.debian.pool.ntp.org to find an NTP server.
Configuration is stored in /etc/systemd/timesyncd.conf
configuration file.
$ 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=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048
Modify this configuration file to use specific NTP servers.
$ cat /etc/systemd/timesyncd.conf
[Time] NTP=time.google.com FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048
Disable NTP service for a moment to reload configuration.
$ sudo timedatectl set-ntp false
$ sudo timedatectl set-ntp true
Inspect systemd service responsible for time synchronization.
$ 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: /usr/lib/systemd/system/systemd-timesyncd.service.d └─disable-with-time-daemon.conf Active: active (running) since Mon 2019-06-03 22:05:08 GMT; 2min 1s ago Docs: man:systemd-timesyncd.service(8) Main PID: 2299 (systemd-timesyn) Status: "Synchronized to time server for the first time 216.239.35.0:123 (time.google.com)." Tasks: 2 (limit: 394) Memory: 1.3M CGroup: /system.slice/systemd-timesyncd.service └─2299 /lib/systemd/systemd-timesyncd
Display detailed service status.
$ timedatectl timesync-status
Server: 216.239.35.0 (time.google.com) Poll interval: 1min 4s (min: 32s; max 34min 8s) Leap: normal Version: 4 Stratum: 1 Reference: GOOG Precision: 1us (-20) Root distance: 213us (max: 5s) Offset: -14.998ms Delay: 35.315ms Jitter: 38.186ms Packet count: 3 Frequency: +382.821ppm
Display detailed service status in machine readable form.
$ timedatectl show-timesync
SystemNTPServers=time.google.com FallbackNTPServers=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org ServerName=time.google.com ServerAddress=216.239.35.0 RootDistanceMaxUSec=5s PollIntervalMinUSec=32s PollIntervalMaxUSec=34min 8s PollIntervalUSec=1min 4s NTPMessage={ Leap=0, Version=4, Mode=4, Stratum=1, Precision=-20, RootDelay=0, RootDispersion=213us, Reference=GOOG, OriginateTimestamp=Mon 2019-06-03 22:06:13 GMT, ReceiveTimestamp=Mon 2019-06-03 22:06:13 GMT, TransmitTimestamp=Mon 2019-06-03 22:06:13 GMT, DestinationTimestamp=Mon 2019-06-03 22:06:13 GMT, Ignored=no PacketCount=3, Jitter=38.186ms } Frequency=25088557
Display specific information.
$ timedatectl show-timesync --property ServerName --value
time.google.com
I really like this idea!