Accurate system time is fundamental for numerous Linux operations, including logging, scheduled tasks (cron jobs), security mechanisms such as certificate validation and Kerberos, and the proper functioning of distributed applications. Synchronizing time across a network ensures consistency and reliability.
Network Time Protocol (NTP)
NTP is the standard internet protocol used to synchronize the clocks of computers to a reference time source. It is designed to mitigate the effects of variable network latency and can achieve high accuracy, often within milliseconds of Coordinated Universal Time (UTC).
Common Time Synchronization Solutions
Modern Linux distributions primarily use one of two NTP clients: chrony or systemd-timesyncd. The older ntpdate command is generally deprecated for continuous time synchronization.

Using Chrony
Chrony is a robust and versatile NTP implementation. It typically synchronizes time faster and with better accuracy, especially on systems with intermittent network connections or those that are frequently suspended or shut down.
- Installation:
Use your distribution's package manager. For example:
- On Debian/Ubuntu:
sudo apt update && sudo apt install chrony
- On RHEL/CentOS/Fedora:
sudo dnf install chrony
(orsudo yum install chrony
on older RHEL/CentOS versions)
- On Debian/Ubuntu:
- Configuration:
The main configuration file is usually
/etc/chrony/*
or/etc/*
. By default, it is often configured to use public NTP server pools (e.g., ). You can add or modify server entries as needed:server *.example iburst
pool * iburst
- Service Management:
Start and enable the chrony service (often named
chronyd
orchrony
):sudo systemctl start chronyd
sudo systemctl enable chronyd
sudo systemctl status chronyd
- Checking Synchronization Status:
chronyc sources
- Displays information about the current time sources and their status.chronyc tracking
- Shows the system's clock accuracy and how it is being corrected.
Using systemd-timesyncd
systemd-timesyncd is a lightweight service provided by systemd that acts as an NTP client. It is often enabled by default on systems running systemd and is suitable for most client machines that do not have complex time synchronization requirements.
- Enabling and Starting:
If not already active, you can enable NTP synchronization:
sudo timedatectl set-ntp true
The service
systemd-timesyncd
should start automatically. You can check its status:sudo systemctl status systemd-timesyncd
- Checking Synchronization Status:
The
timedatectl
command provides an overview:timedatectl status
(or simplytimedatectl
)
Look for "NTP service: active" and "System clock synchronized: yes".
- Configuration:
Configuration is managed in
/etc/systemd/*
. You can specify NTP servers using theNTP=
line if the defaults compiled into systemd are not desired.[Time]
NTP=*.org *.org
FallbackNTP=*
Restart the service after changes:
sudo systemctl restart systemd-timesyncd
.
Legacy Tool: ntpdate
The ntpdate
command was used to set the system time once by querying specified NTP servers. It is generally deprecated for regular use because it performs an immediate, potentially large, step adjustment of the clock. This can be disruptive to running applications and system logs. Modern daemons like chronyd
or systemd-timesyncd
continuously "slew" the clock (gradually adjust its speed), which is much safer.
If you must use it (e.g., on very old systems or for an initial sync before an NTP daemon takes over), ensure no other NTP daemon (like chronyd or systemd-timesyncd) is running. Example usage:
sudo ntpdate *
Manual Time Setting
While NTP synchronization is strongly recommended for accuracy, you can manually set the system date and time using the date
command if the system is isolated or for specific diagnostic purposes. This should be a last resort.

- Set Date and Time:
sudo date -s "YYYY-MM-DD HH:MM:SS"
Example:
sudo date -s "2023-10-27 14:35:00"
- Hardware Clock (RTC):
The system time is distinct from the hardware clock (Real-Time Clock or RTC), which keeps time when the system is powered off.
- To write the current system time to the RTC:
sudo hwclock -w
orsudo hwclock --systohc
- To set the system time from the RTC:
sudo hwclock -s
orsudo hwclock --hctosys
- To write the current system time to the RTC:
Always prioritize using an NTP-based solution for reliable and accurate timekeeping.