Linux VPS

Set the time zone and keep the clock in sync (NTP)

Pick the right time zone with timedatectl, keep the clock accurate with systemd-timesyncd or chrony, and avoid surprises with cron and logs.

BeginnerLinux server2 min read

An accurate clock matters more than it seems: TLS certificates, two-factor codes, database replication and logs all depend on it. The time zone decides how times are displayed and when cron jobs run.

1. Check the current settings

Bash
timedatectl

Look at Time zone and System clock synchronized. It should say yes.

2. Choose a time zone

Many admins keep servers on UTC, which never changes for daylight saving and makes logs from different servers easy to compare. If you prefer local time, find your zone:

Bash
timedatectl list-timezones | grep -i europe

Then set it:

Bash
sudo timedatectl set-timezone UTC
sudo timedatectl set-timezone Europe/Berlin    # or a local zone

3. Keep the clock in sync

Ubuntu and Debian: systemd-timesyncd

Ubuntu uses systemd-timesyncd out of the box. Some Debian 12 minimal images do not include it:

Bash
sudo apt install -y systemd-timesyncd
sudo timedatectl set-ntp true
timedatectl timesync-status

AlmaLinux and Rocky Linux: chrony

Bash
sudo dnf install -y chrony
sudo systemctl enable --now chronyd
chronyc tracking
chronyc sources -v

chronyc tracking shows the current offset. A few milliseconds is normal.

Note: Run only one time service. If chrony is installed on Ubuntu or Debian, it replaces systemd-timesyncd, which is fine; just do not try to run both.

4. Restart services that read the time zone

Cron reads the time zone when it starts. After changing it, restart cron so jobs run at the times you expect:

Bash
sudo systemctl restart cron     # Ubuntu / Debian
sudo systemctl restart crond    # AlmaLinux / Rocky Linux

Applications can have their own setting too, for example date.timezone in PHP or the TZ environment variable for Node.js and Python apps.

Troubleshooting

  • "System clock synchronized: no": check outgoing UDP port 123 is not blocked by your own firewall rules, then restart the time service.
  • Times in logs look wrong after a change: services started before the change keep the old zone until restarted. A reboot fixes them all at once.
  • Large clock jump on start: chrony steps the clock only in the first updates (makestep in /etc/chrony.conf); later it adjusts gradually.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.