System
Difficulty: Beginner
3 min read

NTP Client: Synchronizing Your System Time

Tutorial to install and configure an NTP client on Linux in order to synchronize the system time with reliable time servers.

Back to tutorials
Why is time synchronization so important?
Accurate system time is crucial for many reasons: - Logs must be timestamped correctly for troubleshooting and event correlation. - Security certificates (SSL/TLS) have a validity period. - Authentication protocols such as Kerberos are very sensitive to time discrepancies. - Scheduled tasks (cron) must run at the right time. - Data consistency in distributed systems and databases.

Which NTP client should you use?

On modern Linux systems, you mainly have three choices:

  • systemd-timesyncd: Integrated into systemd. It is the default client on many modern distributions (such as Ubuntu 20.04+). It is very lightweight and simple, perfect for a client. It cannot act as an NTP server.
  • chrony: The modern alternative to ntpd. It performs better on systems that are not always online (laptops) or that have an unstable network connection. It can also act as an NTP server.
  • ntpd: The historical reference implementation. Still very robust, but often considered heavier and more complex than its alternatives for a simple client.

Recommendation: Use systemd-timesyncd if available. If you need more features or want to serve time, use chrony.

Configuring systemd-timesyncd (the simplest option)

It is often already enabled by default.

Step 1: Check the status

timedatectl status

Look for the line `NTP service: active`. If that is the case, you have nothing to do!

Step 2: Enable it if necessary

sudo timedatectl set-ntp true

Step 3: (Optional) Change the NTP servers

The servers are configured in /etc/systemd/timesyncd.conf.

sudo nano /etc/systemd/timesyncd.conf

Uncomment and edit the `NTP=` line to add your servers, separated by spaces.

[Time]
NTP=0.fr.pool.ntp.org 1.fr.pool.ntp.org

Restart the service to apply the changes:

sudo systemctl restart systemd-timesyncd

Configuring chrony

If you prefer chrony or if timesyncd is not available.

Step 1: Installation

# First, disable timesyncd if it is active
sudo timedatectl set-ntp false

# On Debian / Ubuntu
sudo apt-get install -y chrony

# On CentOS / RHEL
sudo yum install -y chrony

Step 2: Configuration

The configuration file is /etc/chrony/chrony.conf (or /etc/chrony.conf).

sudo nano /etc/chrony/chrony.conf

The default configuration often uses server pools. You can replace them with servers closer to your location (e.g. `fr.pool.ntp.org` for France).


# Use servers from the French NTP pool.
pool 2.fr.pool.ntp.org iburst

# ... other options

Step 3: Start and enable the service

sudo systemctl start chronyd
sudo systemctl enable chronyd

Step 4: Verify the synchronization

The chronyc command is the tool to interact with the chronyd daemon.

chronyc sources -v

This command lists the time sources, their status and the offset.

chronyc tracking

This command gives a summary of the system clock synchronization.

The `iburst` parameter
The iburst option, present in the default configurations, is very useful. It tells the client to send a burst of packets at startup to speed up the first synchronization.
Firewall
NTP uses port 123 over UDP. If you have a restrictive firewall, make sure that outbound traffic on this port is allowed.

Conclusion

Maintaining accurate system time is a simple but fundamental background task for any system administrator. With modern tools such as systemd-timesyncd and chrony, configuring an NTP client has become extremely simple. There is no reason not to enable it on all your Linux servers.

Written by

Morgann Riu

Cybersecurity and Linux administration expert. I share my knowledge through free tutorials and training to help system administrators and developers secure their infrastructures.

Frequently asked questions

systemd-timesyncd or chrony, which one should I pick?
Go with systemd-timesyncd if it is available and the machine is a plain client on a stable connection: it is already there, lightweight, and fully driven by timedatectl. Switch to chrony if the machine is not always online (a laptop), if the network is unstable, or if you also need to distribute time to other machines — timesyncd cannot act as an NTP server.
Do I have to disable systemd-timesyncd before installing chrony?
Yes, absolutely: two NTP clients steering the same system clock fight each other and produce erratic synchronisation. Run sudo timedatectl set-ntp false before installing chrony, then start chronyd. You can then confirm with timedatectl status that timesyncd is no longer active.
How do I confirm the clock is actually synchronised and not just configured?
With timesyncd, timedatectl status must show NTP service: active. With chrony, chronyc tracking gives the summary of the system clock state, and chronyc sources -v lists each time source with its status and offset. A running service proves nothing on its own: what matters is the offset reported by those commands.
The service is running but no source ever answers, what should I check first?
The firewall. NTP uses UDP port 123, and many restrictive policies only allow outbound TCP: outbound traffic on 123/UDP must be explicitly permitted. Then make sure only one NTP daemon is running on the machine and that the declared servers (for example 2.fr.pool.ntp.org) resolve correctly in DNS.
What does the iburst keyword actually do?
Without iburst, the client polls at the normal interval and the first synchronisation can take several minutes after boot. With iburst, it sends a burst of packets right at startup and converges almost immediately. That is why it appears in nearly every default configuration, and there is no reason to remove it.

Share this tutorial

Did you enjoy this article?

Comments

Checklist Sécurité Linux

30 points essentiels pour sécuriser un serveur Linux. Recevez aussi les nouveaux tutoriels par email.

Pas de spam. Désabonnement en 1 clic.