Time drift breaks TLS, logs, Kerberos, cron, and more. Here’s a fast, copy‑pasteable guide to bring the clock into sync on today’s major Linux distributions—without wading through man pages.
TL;DR – One‑liners
- chrony (most common on servers):
12 sudo systemctl enable --now chronyd && sudo chronyc -a makestep && sudo hwclock --systohc- systemd‑timesyncd (minimal hosts/containers):
12 sudo timedatectl set-ntp true && sudo systemctl restart systemd-timesyncd && sudo hwclock --systohc- Legacy ntpd:
12 sudo systemctl enable --now ntpd && sudo ntpd -gq && sudo hwclock --systohcVerify:
12 timedatectl status
What you’re doing (and why)
- Enable a time service so the clock keeps syncing (chrony, timesyncd, or ntpd).
- Force an immediate step to fix any large drift now.
- Write to hardware clock so the setting persists across reboots.
Pick the right command for your distro
RHEL / CentOS / AlmaLinux / Rocky (7–9)
Default is chrony (RHEL 7+). Use:
|
1 2 |
sudo systemctl enable --now chronyd && sudo chronyc -a makestep && sudo hwclock --systohc |
Check:
|
1 2 |
chronyc tracking && chronyc sources -v |
Amazon Linux 2 & 2023
Amazon Linux defaults to chrony. Use the same commands:
|
1 2 |
sudo systemctl enable --now chronyd && sudo chronyc -a makestep && sudo hwclock --systohc |
Ubuntu / Debian
Server installs often ship with systemd-timesyncd by default; many admins prefer chrony for richer controls. Pick one:
- timesyncd (simple):
12sudo timedatectl set-ntp true && sudo systemctl restart systemd-timesyncd && sudo hwclock --systohc - chrony (recommended on servers):
1234sudo apt-get update && sudo apt-get install -y chrony \&& sudo systemctl enable --now chronyd \&& sudo chronyc -a makestep && sudo hwclock --systohc
SUSE / openSUSE
Modern releases use chrony:
|
1 2 |
sudo systemctl enable --now chronyd && sudo chronyc -a makestep && sudo hwclock --systohc |
Older/Legacy hosts using ntpd
If you’re stuck on ntpd:
|
1 2 |
sudo systemctl enable --now ntpd && sudo ntpd -gq && sudo hwclock --systohc |
Tip: ntpd -gq corrects large offsets once and exits; the service keeps it in sync afterward.
How to tell what you’re running
|
1 2 3 4 5 6 7 8 9 |
# Is chrony active? systemctl is-active --quiet chronyd && echo "chrony" # Is systemd-timesyncd present? systemctl list-unit-files | grep -q systemd-timesyncd && echo "timesyncd" # Is ntpd installed? command -v ntpd >/dev/null && echo "ntpd" # Quick status view sudo timedatectl status |
Verify it worked
- Universal:
timedatectl status(look forSystem clock synchronized: yes). - chrony:
chronyc tracking(checkReference ID,Root delay,Offset). - ntpd:
ntpq -p(see peers and reachability).
You should also see your timezone and NTP service enabled:
|
1 2 |
timedatectl | sed -n '1,6p' |
Common gotchas (quick fixes)
- No network egress to NTP: allow UDP/123 to the internet or your internal NTP servers.
- Virtual machines drifting: ensure the hypervisor provides stable time; still keep NTP in the guest.
- Containers: prefer the host to handle time; in a container use
timedatectl/timesyncd only if it’s a full systemd container. For app containers, avoid bundling NTP. - Large jumps fail to smooth:
chronyc -a makestep(chrony) orntpd -gq(ntpd) permits big corrections. - Hardware clock errors: some cloud VMs don’t expose a hardware clock—omit
hwclock --systohcif it errors.
One command to “just fix it” (best‑effort)
If you’re not sure which client you have, this tries chrony → timesyncd → ntpd, then writes the hardware clock:
|
1 2 3 4 5 |
( command -v chronyc >/dev/null && sudo systemctl enable --now chronyd && sudo chronyc -a makestep ) \ || ( systemctl list-unit-files | grep -q systemd-timesyncd && sudo timedatectl set-ntp true && sudo systemctl restart systemd-timesyncd ) \ || ( command -v ntpd >/dev/null && sudo systemctl enable --now ntpd && sudo ntpd -gq ); \ sudo hwclock --systohc || true |
Appendix: Point to your own NTP servers
- chrony: edit
/etc/chrony.conf(or/etc/chrony/chrony.confon Debian/Ubuntu) and replacepool …lines withserver ntp1.example.com iburstentries. Thensudo systemctl restart chronyd. - timesyncd: set
NTP=ntp1.example.com ntp2.example.comin/etc/systemd/timesyncd.conf, thensudo systemctl restart systemd-timesyncd. - ntpd: set
server ntp1.example.com iburstin/etc/ntp.conf, thensudo systemctl restart ntpd.
Quick copy‑paste checklist
- Pick your client: chrony / timesyncd / ntpd.
- Run the one‑liner to sync now.
- Verify with
timedatectl status(andchronyc trackingorntpq -p). - (Optional) Set your own NTP servers.
- Confirm it’s enabled to start on boot.
Got a corner case we should add? Ping Reliable Penguin and we’ll expand this guide.




