I have an Ubuntu server that is a little over a minute out of sync with the actual time. When I run timedatectl I get:
Local time: Tue 2018-04-24 14:47:57 MDT
Universal time: Tue 2018-04-24 20:47:57 UTC
RTC time: Tue 2018-04-24 20:47:57
Timezone: America/Denver (MDT, -0600)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2018-03-11 01:59:59 MST
Sun 2018-03-11 03:00:00 MDT
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2018-11-04 01:59:59 MDT
Sun 2018-11-04 01:00:00 MST
My understanding is that it should be synchronizing using NTP. It's possible ntp isn't working quite right. If I run ntpq -p I get:
remote refid st t when poll reach delay offset jitter
======================================================================
propjet.latt.ne .INIT. 16 u - 1024 0 0.000 0.000 0.000
time-a-g.nist.g .INIT. 16 u - 1024 0 0.000 0.000 0.000
linode227395.st .INIT. 16 u - 1024 0 0.000 0.000 0.000
dev.smatwebdesi .INIT. 16 u - 1024 0 0.000 0.000 0.000
pugot.canonical .INIT. 16 u - 1024 0 0.000 0.000 0.000
Is there a way to tell when the last time was that it synced and from what server. Also, how do I force synchronization right now to fix the problem (I know I can manually set the date, but I won't get it quite right, and I want to actually fix the syncing).
Best Answer
Checking status
Since Ubuntu 16.04 timesyncd which is part of systemd is now responsible (out of the box) for syncing date/time. You can check its status using
systemctl
:Or through
journalctl
:You can also watch
systemd/clock
:The Access/Modify/Change times on this file show when systemd-timesynd last touched it.
Forcing a sync
It doesn't appear that there's any method to force a sync directly. Restarting the
systemd-timesyncd
service does in fact trigger a resync though:You can see this in the logs:
The last line is from my restart.
Controlling interval
You can control the interval which this polls the NTP servers through these properties in the
systemd-timesyncd
config file/etc/systemd/timesyncd.conf
:The above appears to have been added in late 2017 - timesync: make poll interval configurable #7268.
References