Quick Guide: Sync the Clock on Any Linux Server

Keep Linux clocks correct in seconds. This quick guide gives copy‑paste one‑liners for chrony, systemd‑timesyncd, and legacy ntpd across RHEL/Alma/Rocky, Amazon Linux, Ubuntu/Debian, and SUSE. Includes verification commands, common gotchas, and how to point at your own NTP servers.

Table of Contents

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):
  • systemd‑timesyncd (minimal hosts/containers):
  • Legacy ntpd:

Verify:


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:

Check:

Amazon Linux 2 & 2023

Amazon Linux defaults to chrony. Use the same commands:

Ubuntu / Debian

Server installs often ship with systemd-timesyncd by default; many admins prefer chrony for richer controls. Pick one:

  • timesyncd (simple):
  • chrony (recommended on servers):

SUSE / openSUSE

Modern releases use chrony:

Older/Legacy hosts using ntpd

If you’re stuck on ntpd:

Tip: ntpd -gq corrects large offsets once and exits; the service keeps it in sync afterward.


How to tell what you’re running


Verify it worked

  • Universal: timedatectl status (look for System clock synchronized: yes).
  • chrony: chronyc tracking (check Reference ID, Root delay, Offset).
  • ntpd: ntpq -p (see peers and reachability).

You should also see your timezone and NTP service enabled:


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) or ntpd -gq (ntpd) permits big corrections.
  • Hardware clock errors: some cloud VMs don’t expose a hardware clock—omit hwclock --systohc if 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:


Appendix: Point to your own NTP servers

  • chrony: edit /etc/chrony.conf (or /etc/chrony/chrony.conf on Debian/Ubuntu) and replace pool … lines with server ntp1.example.com iburst entries. Then sudo systemctl restart chronyd.
  • timesyncd: set NTP=ntp1.example.com ntp2.example.com in /etc/systemd/timesyncd.conf, then sudo systemctl restart systemd-timesyncd.
  • ntpd: set server ntp1.example.com iburst in /etc/ntp.conf, then sudo systemctl restart ntpd.

Quick copy‑paste checklist

  1. Pick your client: chrony / timesyncd / ntpd.
  2. Run the one‑liner to sync now.
  3. Verify with timedatectl status (and chronyc tracking or ntpq -p).
  4. (Optional) Set your own NTP servers.
  5. Confirm it’s enabled to start on boot.

Got a corner case we should add? Ping Reliable Penguin and we’ll expand this guide.

Have a project or a problem?

Talk with a senior engineer for practical recommendations—no obligation.

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.