An incorrect system clock causes subtle but serious problems: cron jobs firing at the wrong time, SSL certificate validation failures, misleading log timestamps, and 2FA codes being rejected. This guide covers setting the timezone and keeping the clock accurately synced.
Checking Current Time and Timezone
timedatectl
Listing Available Timezones
timedatectl list-timezones | grep -i london
Setting the Timezone
sudo timedatectl set-timezone Europe/Oslo
For servers, UTC is often the recommended default — it avoids daylight saving time confusion in logs and cron schedules, especially for teams across multiple regions:
sudo timedatectl set-timezone UTC
Verifying the Change
date
Enabling NTP (Automatic Clock Sync)
sudo timedatectl set-ntp true
Verifying NTP Is Active and Synced
timedatectl
Look for NTP service: active and System clock synchronized: yes.
Checking Sync Details with chrony (If Installed)
sudo apt install chrony -y
sudo systemctl enable --now chrony
chronyc tracking
Why This Matters for SSL/TLS
Certificate validation depends on accurate time — if your server's clock is significantly off, HTTPS connections and Let's Encrypt renewals can fail with certificate validity errors even though the certificate itself is correct.
Why This Matters for 2FA
Time-based one-time password (TOTP) codes are only valid within a short time window; a clock drift of even a minute or two can cause valid 2FA codes to be rejected.
Common Errors
"System clock not synchronized" — NTP may be disabled or blocked by the firewall. Confirm outbound UDP 123 isn't blocked, and that NTP is enabled: sudo timedatectl set-ntp true.
Cron jobs run at unexpected times after a timezone change — cron uses the system timezone; confirm with date and adjust schedules if needed.
Best Practices
- Use UTC on servers unless there's a specific business reason for local time
- Always enable NTP — never rely on manually set time
- Check
timedatectlafter any major system change or migration
FAQ
Should I use UTC or my local timezone on a server?
UTC is generally recommended for servers to keep logs and schedules consistent, especially across distributed systems or teams in different time zones.
Continue Reading
- How to Schedule Tasks with Cron on a Linux VPS
- How to Enable Two-Factor Authentication (2FA) for SSH
- How to Read and Analyze Linux Logs with journalctl
Browse more articles in Linux Server Administration.
