How to Set the Correct Timezone and Enable NTP on a Linux VPS

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 timedatectl after 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

Browse more articles in Linux Server Administration.

  • timezone, ntp, chrony, system clock, server administration
  • 0 Los Usuarios han Encontrado Esto Útil
¿Fue útil la respuesta?

Artículos Relacionados

How to Update and Upgrade Your Ubuntu or Debian VPS

Keeping your VPS updated is one of the most important and simplest maintenance tasks — it...

How to Enable and Configure Swap on a Linux VPS (Ubuntu & Debian)

Swap is disk space Linux can use as overflow memory when physical RAM is exhausted. It won't make...

How to Manage Services with systemd and systemctl

systemd is the service manager used by Ubuntu, Debian, and most modern Linux distributions to...

How to Read and Analyze Linux Logs with journalctl

On modern Ubuntu and Debian systems, journalctl is the central tool for viewing system and...

How to Schedule Tasks with Cron on a Linux VPS

Cron is the standard Linux job scheduler, used to automate recurring tasks like backups, log...