Time Synchronization (NTP / Chrony)
Configure automatic time synchronization on your VPS with Chrony or systemd-timesyncd.
An unsynchronized system clock causes problems with SSL, logs, cron jobs and authentication (2FA, JWT, certificates).
Check current status
timedatectl statusExpected output:
System clock synchronized: yes
NTP service: activeIf it shows NTP service: inactive or System clock synchronized: no, time synchronization needs to be enabled.
Option 1: systemd-timesyncd (lightweight, already included)
The simplest method: available on Ubuntu 18.04+ and Debian 9+.
# Enable and start service
systemctl enable --now systemd-timesyncd
# Verify
timedatectl timesync-statusConfigure NTP servers in /etc/systemd/timesyncd.conf:
[Time]
NTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
FallbackNTP=ntp.ubuntu.comsystemctl restart systemd-timesyncdOption 2: Chrony (recommended for production servers)
Chrony is more precise and adapts better to network variations.
Installation
# Debian / Ubuntu
apt install chrony -y
# AlmaLinux / CentOS
dnf install chrony -yConfiguration
nano /etc/chrony.conf# Public NTP servers (pool.ntp.org)
pool 0.pool.ntp.org iburst maxsources 2
pool 1.pool.ntp.org iburst maxsources 2
pool 2.pool.ntp.org iburst maxsources 2
# Permit rapid slew if offset > 1s
makestep 1.0 3
# Drift file
driftfile /var/lib/chrony/drift
# Log
logdir /var/log/chronysystemctl enable --now chronyd
# Verify synchronization
chronyc tracking
chronyc sources -vOutput of chronyc tracking:
Reference ID : 85.21.78.91 (ntp1.example.net)
Stratum : 2
System time : 0.000012345 seconds fast of NTP time
Last offset : +0.000009123 seconds
RMS offset : 0.000008234 seconds
Frequency : 12.345 ppm slowSet timezone
# List available timezones
timedatectl list-timezones | grep Europe
# Set (example: Rome)
timedatectl set-timezone Europe/Rome
# Verify
dateResolve misaligned clock
If the clock is very different from the real time:
# With Chrony: force immediate synchronization
chronyc makestep
# With systemd-timesyncd: restart service
systemctl restart systemd-timesyncd
timedatectl set-ntp trueSlew vs Step
By default, Chrony corrects the clock gradually (slew) to not disturb logs. If you have an offset greater than 3 seconds, use chronyc makestep to correct immediately.
Final verification
timedatectl status
date
chronyc tracking # if using ChronyAll correct if you see synchronized: yes and the local time matches.