Time Synchronization (NTP / Chrony)

An unsynchronized system clock causes problems with SSL, logs, cron jobs and authentication (2FA, JWT, certificates).

02

Check current status

bash
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.

03

Option 1: systemd-timesyncd (lightweight, already included)

The simplest method: available on Ubuntu 18.04+ and Debian 9+.

bash
# Enable and start service
systemctl enable --now systemd-timesyncd

# Verify
timedatectl timesync-status

Configure NTP servers in /etc/systemd/timesyncd.conf:

ini
[Time]
NTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
FallbackNTP=ntp.ubuntu.com
bash
systemctl restart systemd-timesyncd
04

Option 2: Chrony (recommended for production servers)

Chrony is more precise and adapts better to network variations.

Installation

bash
# Debian / Ubuntu
apt install chrony -y

# AlmaLinux / CentOS
dnf install chrony -y

Configuration

bash
nano /etc/chrony.conf
ini
# 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
bash
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
05

Set timezone

bash
# List available timezones
timedatectl list-timezones | grep Europe

# Set (example: Rome)
timedatectl set-timezone Europe/Rome

# Verify
date
06

Resolve misaligned clock

If the clock is very different from the real time:

bash
# 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.

07

Final verification

bash
timedatectl status
date
chronyc tracking   # if using Chrony

All correct if you see synchronized: yes and the local time matches.

DeluxHost, opgericht in 2023, biedt hoogwaardige hostingoplossingen voor diverse digitale behoeften. Wij bieden gedeelde hosting, VPS en dedicated servers met geavanceerde beveiliging en wereldwijde datacenters.

© DeluxHost, Alle rechten voorbehouden. | BTW-nummer: IT17734661006
Alle systemen operationeel