Debian time sync is the process of keeping your system clock accurate by automatically synchronizing it with remote time servers, most commonly using the Network Time Protocol (NTP). You configure it by installing and enabling a time synchronization daemon—usually systemd-timesyncd (preinstalled) or the more feature-rich chrony—and then checking its status with timedatectl. This article explains how to set it up, how it works, and how to fix common problems.
Why Time Sync Matters
An accurate system clock is not just about displaying the correct time. Many critical operations depend on it:
- Log correlation: When troubleshooting across multiple servers, timestamps must match.
- Authentication: Kerberos and many SSO systems reject tickets if clocks are skewed by more than a few minutes.
- File timestamps: Build tools like
makeand version control systems rely on file modification times. - Scheduled tasks:
cronjobs run at specific times; if the clock drifts, they run at the wrong moment. - Security: TLS certificates have validity periods; a clock far in the past or future can cause handshake failures.
Without synchronization, a typical PC clock drifts by seconds per day; a server may drift more depending on hardware and load.
How NTP Works
NTP (Network Time Protocol) operates over UDP port 123. Your system sends a request to a time server, which replies with its current time. The client measures the round-trip delay and adjusts its clock accordingly. It does not simply set the clock to the server's time; it calculates an offset and applies it gradually to avoid sudden jumps (unless the offset is large).
Time servers are organized in a hierarchy (strata). Stratum 0 are atomic clocks and GPS receivers. Stratum 1 servers sync directly from stratum 0. Stratum 2 sync from stratum 1, and so on. Your Debian system typically syncs from a pool of stratum 2 or 3 servers. The public NTP pool project (pool.ntp.org) provides a set of geographically distributed servers for general use.
Debian's default configuration uses the Debian NTP pool: 0.debian.pool.ntp.org, 1.debian.pool.ntp.org, etc. These are aliases that resolve to a random set of servers, so you don't need to pick a specific one.
Choosing a Sync Method
Debian offers three main ways to sync time:
- systemd-timesyncd — A lightweight SNTP client built into systemd. It is installed by default on most Debian systems and is sufficient for most desktops and laptops. It only synchronizes the clock; it does not provide a time server to other machines.
- chrony — A full-featured NTP implementation that is faster to synchronize and better at handling intermittent network connections (e.g., laptops that sleep). It can also act as a server. Recommended for most users who need more control.
- NTP (the classic ntpd) — The original reference implementation. It is more complex and heavier than chrony, but still widely used. On Debian, the package is
ntp(orntpsec). It is a good choice for servers that need to serve time to many clients.
For a typical desktop, systemd-timesyncd is fine. For servers or systems that need precise time, chrony is the recommended modern alternative. The classic ntpd is still valid but may be overkill.
How to Set Up Time Sync
Here are the steps for each method.
Using systemd-timesyncd (default)
- Check if it is active:
timedatectl status. Look forSystem clock synchronized: yesandNTP service: active. - If not, enable it:
sudo timedatectl set-ntp true. - To change the servers, edit
/etc/systemd/timesyncd.confand setNTP=to your preferred pool, e.g.,NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org. - Restart the service:
sudo systemctl restart systemd-timesyncd.
Using chrony
- Install:
sudo apt install chrony. - It will automatically disable
systemd-timesyncdbecause both cannot run simultaneously. - Edit
/etc/chrony/chrony.confto set your server pool (the default is fine). - Restart:
sudo systemctl restart chrony. - Check status:
chronyc trackingandchronyc sources -v.
Using classic ntpd
- Install:
sudo apt install ntp. - Edit
/etc/ntp.confto set servers (default is the Debian pool). - Restart:
sudo systemctl restart ntp. - Check:
ntpq -p.
After any method, verify with timedatectl. It should show synchronized: yes and NTP service: active.
Common Problems and Fixes
- NTP service is inactive (dead): This usually means another NTP client is installed. Run
sudo systemctl status systemd-timesyncdandsudo systemctl status chronyto see which is active. Only one can run at a time. - System clock not synchronized: Check network connectivity to the NTP servers:
ping 0.debian.pool.ntp.org. Also check that UDP port 123 is not blocked by a firewall. - Time is wrong by many hours: This often indicates the timezone is set incorrectly. Use
sudo timedatectl set-timezone Region/City(e.g.,America/New_York). - chrony won't sync: Run
chronyc sourcesand look for^*(selected) or^-(unreachable). If all are unreachable, check DNS and firewall. - ntpd won't sync: Check
ntpq -p. If thereachcolumn is 0, the server is unreachable. Also check for a local clock conflict (e.g., a hardware RTC that is off).
Comparison: systemd-timesyncd vs chrony vs ntpd
| Feature | systemd-timesyncd | chrony | ntpd |
|---|---|---|---|
| Default on Debian | Yes | No | No |
| Accuracy | Good (SNTP) | Excellent | Excellent |
| Handles intermittent connections | Poor | Excellent | Good |
| Can act as a server | No | Yes | Yes |
| Configuration complexity | Very simple | Moderate | Complex |
| Resource usage | Very low | Low | Higher |
For most users, systemd-timesyncd is enough. If you run a server that needs to serve time to other machines, or you have a laptop that sleeps often, chrony is the best choice. The classic ntpd is still used in some enterprise environments but is generally considered legacy.
Safety and Accuracy Considerations
- Never run multiple NTP daemons simultaneously. They will conflict and cause erratic clock behavior. When you install
chronyorntp, Debian automatically disablessystemd-timesyncd. - Use the Debian pool or a trusted NTP server. The pool is managed by volunteers and is reliable. Avoid using random public servers you find on the internet.
- Consider using a local NTP server on your network for many machines to reduce external traffic and improve consistency.
- Be aware of the hardware clock (RTC). Debian can set the RTC to UTC or local time. It is recommended to keep the RTC in UTC and let the operating system convert to local time. Check with
timedatectl; the lineRTC in local TZ: nois the recommended setting. - For critical systems, use multiple servers. The default configuration uses several servers; you can add more in the config file.
Frequently Asked Questions
How do I check if time sync is enabled?
Run timedatectl. Look for System clock synchronized: yes and NTP service: active. If NTP service is inactive, you need to enable it with sudo timedatectl set-ntp true or install a daemon.
What is the difference between SNTP and NTP?
SNTP (Simple Network Time Protocol) is a simplified version of NTP. It is less accurate and does not have the full error estimation and filtering algorithms. systemd-timesyncd uses SNTP, while chrony and ntpd use full NTP. For most purposes, SNTP is sufficient, but for high precision, use NTP.
Why is my time still wrong after enabling NTP?
If the time is off by hours, the timezone is likely wrong. Use sudo timedatectl set-timezone Your/Zone. If the time is off by minutes, check that the NTP service is actually running and can reach servers. Also check the hardware clock: sudo hwclock --show.
Can I use a public NTP server instead of the Debian pool?
Yes, you can edit the configuration file of your sync daemon and add any NTP server. However, the Debian pool is reliable and geographically distributed. If you use a specific server, make sure it is trustworthy and has good availability.
Does time sync work when the system is asleep?
No, when the system is asleep, the NTP daemon is suspended. On wake, it will resynchronize. chrony is particularly good at handling this because it can quickly sync after a long sleep. systemd-timesyncd may take longer to catch up.
How do I force an immediate sync?
For systemd-timesyncd, restart the service: sudo systemctl restart systemd-timesyncd. For chrony, use sudo chronyc makestep (this forces an immediate step). For ntpd, use sudo ntpdate -u pool.ntp.org (but this is not recommended if ntpd is running).