Time Synchronization (NTP / Chrony)
An unsynchronized system clock causes problems with SSL, logs, cron jobs and authentication (2FA, JWT, certificates).
Check current status
timedatectl status
Expected output:
System clock synchronized: yes
NTP service: active
If 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-status
Configure NTP servers in /etc/systemd/timesyncd.conf:
[Time]
NTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
FallbackNTP=ntp.ubuntu.com
systemctl restart systemd-timesyncd
Option 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 -y
Configuration
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/chrony
systemctl enable --now chronyd
# Verify synchronization
chronyc tracking
chronyc sources -v
Output 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 slow
Set timezone
# List available timezones
timedatectl list-timezones | grep Europe
# Set (example: Rome)
timedatectl set-timezone Europe/Rome
# Verify
date
Resolve 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 true
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 Chrony
All correct if you see synchronized: yes and the local time matches.
Verwandte Artikel
Server Reboot
How to properly restart your VPS or VDS, both via SSH and from the control panel
Resource Monitoring
How to check CPU, RAM, disk and network on your server in real time
Disk Management
How to check disk space, find large files and free up disk space
