How to set timezone and sync time with NTP
Topic: Servers linux
Summary
Set the system timezone with timedatectl or a symlink in /usr/share/zoneinfo, and enable NTP (systemd-timesyncd or chrony) so the clock stays correct. Use this when deploying a server, fixing certificate or log ordering issues, or after restoring a snapshot.
Intent: How-to
Quick answer
- timedatectl set-timezone Europe/London sets timezone and persists it; timedatectl status shows timezone and NTP sync status. No reboot needed.
- Enable NTP: timedatectl set-ntp true (uses systemd-timesyncd if available); or install and enable chrony; ensure outbound UDP 123 is allowed if behind a firewall.
- List timezones with timedatectl list-timezones; legacy systems use ln -sf /usr/share/zoneinfo/Region/City /etc/localtime.
Prerequisites
Steps
-
Set timezone
sudo timedatectl set-timezone America/New_York; timedatectl status shows Time zone. To list options: timedatectl list-timezones | grep -i city.
-
Enable NTP
sudo timedatectl set-ntp true; systemctl status systemd-timesyncd. If using chrony, install chrony, enable and start it, and disable systemd-timesyncd to avoid conflict.
-
Verify sync
timedatectl status shows System clock synchronized: yes and NTP service: active. chronyc tracking if using chrony; allow UDP 123 outbound if sync fails and you use an external NTP server.
Summary
Set timezone with timedatectl and enable NTP so the system clock is correct and consistent. Use this on new servers, after restores, or when debugging time-sensitive issues (certs, logs).
Prerequisites
- Root or sudo; systemd (for timedatectl and systemd-timesyncd).
Steps
Step 1: Set timezone
sudo timedatectl set-timezone America/New_York
timedatectl status
Step 2: Enable NTP
sudo timedatectl set-ntp true
systemctl status systemd-timesyncd
If you use chrony instead, enable chronyd and disable systemd-timesyncd.
Step 3: Verify sync
timedatectl status should show NTP active and clock synchronized. If using chrony, run chronyc tracking.
Verification
dateshows correct timezone and time;timedatectl statusshows NTP active and synchronized.
Troubleshooting
NTP not syncing — Firewall may block UDP 123; use an internal NTP server or allow outbound to pool.ntp.org. Wrong time after VM snapshot — Re-enable NTP and wait for sync, or run chronyc makestep (chrony) once.