The clock is not synchronised
- Check
time.sync- Severity
- low
- Runs
- on the server, in the daily run of the agent
- Looks at
- systemd-timesyncd, chrony or ntpd active and synchronised
What the check looks at
Whether a time service runs (systemd-timesyncd, chrony or ntpd), and whether the kernel reports the clock as
synchronised: the state that timedatectl status shows in the line System clock synchronized. The check fails
when the clock is not synchronised.
Risk
With a clock that is off by minutes or days, valid TLS certificates look expired or not yet valid, and outgoing HTTPS calls, package downloads and API clients fail. One-time codes (TOTP) fail too, as they are valid for a time step of 30 seconds by default, and during an incident the logs of several servers do not line up. A wrong clock does not open a way in, so the severity is low, but the failures it causes are hard to trace.
How to fix it
Debian and Ubuntu
Install systemd-timesyncd or chrony. The two packages conflict, so installing one removes the other.
sudo apt install systemd-timesyncd
sudo timedatectl set-ntp true
or
sudo apt install chrony
RHEL, Rocky Linux and AlmaLinux
chrony is the default:
sudo dnf install chrony
sudo systemctl enable --now chronyd
Alpine
sudo apk add chrony
sudo rc-update add chronyd default
sudo rc-service chronyd start
The time service needs outgoing UDP to port 123. If a firewall blocks outgoing traffic, allow it to the NTP
servers in the configuration (/etc/systemd/timesyncd.conf; /etc/chrony/chrony.conf on Debian and Ubuntu,
/etc/chrony.conf on RHEL).
How to check the fix
timedatectl status
The lines System clock synchronized: yes and NTP service: active must appear. With chrony:
chronyc tracking
chronyc sources
Leap status : Normal in the first output and a source marked ^* in the second mean that the clock follows a
server.
When a warning is fine
Right after a boot, the first synchronisation can take a minute or two; the next report clears the result. On a
virtual machine where the hypervisor keeps the clock and no NTP server is reachable, check once with date -u
that the time is right, then accept the result on the dashboard.
An accepted result stays out of the digest and the counts until it changes.
Sources
- timedatectl(1) (
status,show,set-ntp) - chronyc(1) (
tracking,sources) - RFC 6238, TOTP (default time step of 30 seconds)