How to update system time using systemd

Update the system time using systemd as a NTP client.

Debian is by default using 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.

Modify this configuration file to use specific NTP servers.

$ cat  /etc/systemd/timesyncd.conf

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
   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 ("
    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: (
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
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 }

Display specific information.

$ timedatectl show-timesync  --property ServerName --value

I really like this idea!