Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Synchronize Time with NTP in Linux

· 6 min read · Home Tech

In this article
  1. Why Accurate Time Matters
  2. How NTP Works
  3. Choosing an NTP Implementation
  4. How to Synchronize Time with systemd-timesyncd
  5. How to Synchronize Time with chrony
  6. Common Problems and Troubleshooting
  7. Comparing chrony vs systemd-timesyncd
  8. Frequently Asked Questions

To synchronize time with NTP in Linux, you install and enable an NTP client daemon such as chrony or systemd-timesyncd, then start it so your system clock continuously adjusts to match atomic clocks via internet time servers. The most common modern approach is timedatectl with systemd-timesyncd for basic sync, or chrony for more advanced needs.

Why Accurate Time Matters

Linux systems rely on accurate time for more than just displaying the clock. Log timestamps, cron job schedules, certificate validation, database replication, and authentication protocols like Kerberos all break when the clock drifts. A server that is even a few seconds off can fail to authenticate with other systems or produce logs that are impossible to correlate during troubleshooting. NTP (Network Time Protocol) corrects this by keeping your system clock within milliseconds of Coordinated Universal Time (UTC).

How NTP Works

NTP uses a hierarchical model of time sources. Stratum 0 devices are atomic clocks and GPS receivers. Stratum 1 servers connect directly to those, and Stratum 2 servers sync from Stratum 1, and so on. Your Linux machine typically queries several Stratum 2 or Stratum 3 public servers. The protocol exchanges timestamps over UDP port 123, calculates the round-trip delay and offset, and then adjusts the local clock gradually (slewing) or in one jump (stepping) if the offset is large. The daemon repeats this periodically, usually every 64 seconds to several minutes, and also monitors the stability of each server to avoid using a faulty one.

Choosing an NTP Implementation

Linux offers three main ways to sync time:

  • systemd-timesyncd – A lightweight client built into systemd. It is sufficient for most desktop and simple server setups. It only acts as a client, not a server, and lacks advanced features like hardware timestamping.
  • chrony – The recommended full-featured NTP implementation on modern distributions. It syncs faster, handles intermittent network connections well, and can also act as an NTP server for other machines. It is the default on RHEL, Fedora, and Ubuntu Server.
  • ntpd (classic) – The original reference implementation. It is older, slower to converge, and less accurate on virtual machines, but still found on some legacy systems.

For most users, systemd-timesyncd is enough. If you run a server that needs high accuracy or provides time to other devices, choose chrony.

How to Synchronize Time with systemd-timesyncd

On most distributions with systemd, you can enable time synchronization with these steps:

  1. Check if it is already active: timedatectl
  2. If NTP service: active is shown, you are done. If not, run sudo timedatectl set-ntp true
  3. Verify with timedatectl – the NTP service should now be active.
  4. To see the last sync details, use timedatectl timesync-status (available on newer systemd).

If you need to change the NTP servers, edit /etc/systemd/timesyncd.conf and set NTP= to your preferred server pool, then restart with sudo systemctl restart systemd-timesyncd.

How to Synchronize Time with chrony

If you prefer chrony (or your system already uses it), the process is:

  1. Install chrony if not present: sudo apt install chrony (Debian/Ubuntu) or sudo dnf install chrony (Fedora/RHEL).
  2. Edit /etc/chrony/chrony.conf (or /etc/chrony.conf on some systems) to set your server pool. Defaults usually point to distribution-specific pools like pool 2.pool.ntp.org iburst.
  3. Enable and start the service: sudo systemctl enable --now chronyd
  4. Check status with chronyc tracking – it shows the current offset and last sync.
  5. To see the list of servers, use chronyc sources -v.

If you have a firewall, ensure UDP port 123 is open for outgoing packets. Incoming connections are only needed if you run an NTP server.

Common Problems and Troubleshooting

Time sync can fail for several reasons. The most common are:

  • Firewall blocking UDP 123 – Check with sudo ufw status or iptables -L.
  • Virtual machines with a host clock – VMs often have a large offset; chrony handles this better than ntpd. Ensure your hypervisor's time sync is disabled to avoid conflicts.
  • Incorrect timezone – NTP sets UTC internally, but the displayed time depends on your timezone. Set it with sudo timedatectl set-timezone Region/City.
  • Large initial offset – If your clock is off by more than a few minutes, chrony will step it immediately, but systemd-timesyncd may refuse to step unless you set FallbackNTP or manually set the time first with sudo date -s.
  • Multiple NTP daemons running – Having both chronyd and systemd-timesyncd active will cause conflicts. Disable one: sudo systemctl stop systemd-timesyncd and sudo systemctl disable systemd-timesyncd.

If you see timedatectl showing NTP service: inactive even after enabling, check the service logs with journalctl -u systemd-timesyncd.

Comparing chrony vs systemd-timesyncd

Both tools solve the same problem, but they differ in scope. systemd-timesyncd is minimal and perfect for workstations and laptops that only need to keep the clock accurate. It uses less memory and has no configuration overhead. chrony is more powerful: it can act as a server, supports hardware timestamping for high accuracy, and works better on networks with variable latency. For a typical desktop, the difference is negligible. For a server that provides time to a network or runs scientific applications, chrony is the clear choice.

Frequently Asked Questions

What is the difference between NTP and SNTP?

SNTP (Simple Network Time Protocol) is a simplified version of NTP that lacks the complex filtering and statistical algorithms. It is often used in embedded devices and Windows Time service. Linux's systemd-timesyncd actually uses SNTP, but for most purposes the accuracy is sufficient. If you need sub-millisecond precision, use chrony with full NTP.

How often does NTP sync?

By default, NTP daemons poll servers every 64 seconds initially, then adjust the interval based on network stability, up to a maximum of about 1024 seconds (17 minutes). The exact interval is dynamic and depends on the variance of the measurements. You can see the current polling interval in chronyc sources.

Can I sync time without internet access?

Yes, you can use a local time server on your LAN. Configure your NTP client to point to the internal server's IP address. If you have no server at all, you can set the clock manually with date, but it will drift. For isolated networks, you could also use a GPS receiver as a stratum 1 source.

Is it safe to use public NTP pools?

Yes, the NTP Pool Project (pool.ntp.org) is a widely used, reliable network of public time servers. However, you should not hammer a single server; use the pool names like 0.pool.ntp.org which distribute load. For corporate environments, it is better to run your own NTP server and have clients sync from it.

Why is my time still wrong after enabling NTP?

Check if the NTP service is actually running (systemctl status chronyd or timedatectl). Also verify that your system timezone is correct, because NTP sets UTC, and the displayed time is the UTC converted to your timezone. If you are in a VM, disable the host's time sync feature. Finally, check for firewall blocks on UDP 123.