How to Configure Time Synchronization on Ubuntu Server

How to Configure Time Synchronization on Ubuntu Server

Accurate system time is essential for logging, authentication (Kerberos, certificates), distributed systems, databases, cron jobs, and security auditing. Incorrect time can cause subtle failures ranging from failed TLS handshakes to invalid log timestamps.

Ubuntu Server provides two main modern options for time synchronization:

  • systemd-timesyncd — lightweight SNTP client (included in systemd, very low resource usage)
  • chrony — full-featured NTP client/server implementation (higher accuracy, supports NTS, multiple sources, hardware timestamping, better for intermittent connectivity)

Important context for 2026

  • Up to Ubuntu 24.04 LTS → systemd-timesyncd is the default and usually sufficient
  • Starting with Ubuntu 25.10 (non-LTS) → chrony became the default NTP client
  • On upgraded systems (from 24.04 or earlier), systemd-timesyncd may remain active unless chrony is explicitly installed and enabled
  • Canonical documentation now recommends chrony for most production use cases, especially when higher precision, NTS (secure NTP), or acting as a time server is needed

1. Check Current Time Synchronization Status

Use this command on any Ubuntu Server release:

Bash
timedatectl status

Key fields to check:

  • Local time / Universal time — should match your expectation
  • RTC in local TZ — usually no (hardware clock in UTC)
  • System clock synchronizedyes = good
  • NTP serviceactive = synchronization is running
  • time zone — correct setting

Also check which service is actually running:

Bash
systemctl status systemd-timesyncd
systemctl status chronyd

Only one should be active at a time — they conflict if both try to manage the clock.

2. Option A: Using systemd-timesyncd (Simple, Lightweight – Good for Most Servers)

This remains perfectly suitable for the majority of Ubuntu Server deployments in 2026.

Enable and start (if not already active):

Bash
sudo timedatectl set-ntp true

This command enables NTP synchronization via systemd-timesyncd.

Customize NTP servers (optional but recommended):

Edit /etc/systemd/timesyncd.conf or create a drop-in file:

Bash
sudo mkdir -p /etc/systemd/timesyncd.conf.d
sudo nano /etc/systemd/timesyncd.conf.d/custom.conf

Add or modify:

text
[Time]
NTP=time.cloudflare.com time.google.com pool.ntp.org
FallbackNTP=ntp.ubuntu.com

Then apply:

Bash
sudo systemctl restart systemd-timesyncd

Verify synchronization:

Bash
timedatectl status
systemctl status systemd-timesyncd
journalctl -u systemd-timesyncd -n 30

Look for lines like “Synchronized to time server …” or “Reached target time sync”.

3. Option B: Using chrony (Recommended for Higher Accuracy & Modern Features)

chrony offers better accuracy (especially after restarts or on intermittent networks), supports Network Time Security (NTS) by default, can act as an NTP server, and handles hardware timestamping/PPS/GPS.

Install chrony:

Bash
sudo apt update
sudo apt install chrony

Installing chrony automatically disables and masks systemd-timesyncd to avoid conflicts.

Default configuration (Ubuntu 25.10+ style):

  • Uses NTS-enabled Ubuntu pool servers by default
  • Very secure and accurate out of the box

Customize sources (if needed):

Edit files in /etc/chrony/sources.d/ or directly /etc/chrony/chrony.conf

Example additions:

text
# Secure NTS servers (preferred)
server time.cloudflare.com iburst nts
server nts.netnod.se iburst nts

# Classic NTP fallback
pool pool.ntp.org iburst

Restart:

Bash
sudo systemctl restart chrony

Verify chrony status:

Bash
chronyc tracking
chronyc sources -v
chronyc sourcestats
timedatectl status   # shows chrony as active NTP service

chronyc tracking output shows:

  • Reference ID — current best server
  • Stratum — distance from atomic clock
  • Last offset / RMS offset — synchronization quality (sub-ms is excellent)
  • Leap status — Normal / Insert second / Delete second / Not synchronized

4. Best Practices & Recommendations (2026)

  • Use chrony if any of these apply:
    • You need sub-millisecond accuracy
    • Server has intermittent connectivity (laptops, roaming VMs)
    • You want NTS security (encrypted & authenticated time)
    • You plan to serve time to other devices (chrony excels as server)
    • Financial, scientific, logging, or certificate-heavy workloads
  • Stick with systemd-timesyncd if:
    • Minimal resource usage is critical (tiny VMs, IoT-like)
    • Simple client-only sync is sufficient
    • You’re on 24.04 LTS and everything already works
  • Always set the correct timezone first:
Bash
sudo timedatectl set-timezone America/Los_Angeles   # example for your location
timedatectl list-timezones | grep Los_Angeles
  • Prefer pool.ntp.org style pools or NTS-capable servers (time.cloudflare.com, nts.netnod.se) over single servers for redundancy
  • Monitor synchronization health (Prometheus chrony exporter or simple cron + chronyc tracking)
  • For air-gapped networks → configure local GPS/PPS reference clock or use chrony’s “local” stratum directive

Accurate time is a foundational security and reliability property. A mis-synchronized clock is one of the most common causes of mysterious failures in distributed systems.

If your Ubuntu version is 24.04 LTS, 25.10+, or you’re seeing specific symptoms (drift >1s, NTS failures, chrony not starting), share timedatectl status output for more targeted guidance.

Fast • Reliable • Affordable VPS - DO It Now!

Get top VPS hosting with VPS.DO’s fast, low-cost plans. Try risk-free with our 7-day no-questions-asked refund and start today!