From Newroco Tech Docs
Jump to navigationJump to search

A brief history of time (synchronisation)

Time in Linux has traditionally been the responsibility of the ntp service, ntpd, or through periodic time updates using ntpdate command in cron (with cron.hourly usually adequate to keep time in sync for even the more demanding of services (generally auth stuff e.g. smb/cifs, ldap/kerberos etc.). More recently this has been sucked into the sytemd megalith which means where you set stuff and how you force time updates has become "different".

Systemd, timesyncd and timedatectl

To change the default settings of systemd's time service, you have to edit the timesyncd settings

# vi /etc/systemd/timesyncd.conf

And provide a space separated list of timeservers by name or IP:

NTP=my.time.ser.ver ip.add.re.ss1 ip.add.re.ss2

You would normally use the same time sources everywhere within a network (whether that's a LAN or an interdependent set of servers hosted in random places). If you've changed the configuration and want to force the time to be updated immediately then the only way we've so far discovered is to stop using timesyncd's net element and then start using it again:

# timedatectl set-ntp false
# timedatectl set-ntp true

(If anyone knows of a neater way, equivalent of restarting ntpd or using ntpdate, be good to hear it...)

ntpd and ntpdate