Tech/HowTo/Using systemd timesyncd on Debian

From lathama
< Tech‎ | HowTo
Jump to navigation Jump to search

On systems like Debian with systemd, the timesyncd is baked in but will not run at all if the legacy NTP package is installed so here is a howto/demo of what to do.

TL;DR;
apt-get purge ntp
apt-mark hold ntp
systemctl restart systemd-timesyncd.service
systemctl status systemd-timesyncd.service
In detail
apt-get purge ntp
apt-mark hold ntp
systemctl restart systemd-timesyncd.service
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 Fri 2017-08-11 10:09:11 CDT; 3s ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 31413 (systemd-timesyn)
   Status: "Synchronized to time server 92.243.6.5:123 (0.debian.pool.ntp.org)."
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/systemd-timesyncd.service
           └─31413 /lib/systemd/systemd-timesyncd

Aug 11 10:09:11 nodeone systemd[1]: Starting Network Time Synchronization...
Aug 11 10:09:11 nodeone systemd[1]: Started Network Time Synchronization.
Aug 11 10:09:11 nodeone systemd-timesyncd[31413]: Synchronized to time server 92.243.6.5:123 (0.debian.pool.ntp.org).
Configuration

In /etc/systemd/timesyncd.conf there is a template showing any options it was compiled with. The defaults are complied in normally by the packager/distro. To set your own NTP sources just edit the file as directed and restart the service.

Package

In a minimal install you may need to manually install

apt install systemd-timesyncd

Resources