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.

  • Beginner
  • Linux VPS
  • 2 min read

By RunRacks Team · Published

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

Terminal
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:

Terminal
timedatectl list-timezones | grep -i europe

Then set it:

Terminal
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:

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

AlmaLinux and Rocky Linux: chrony

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

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:

Terminal
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 RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.

Linux VPS

Deploy a Node.js app with PM2 behind Nginx

Install a Node.js LTS release, keep your app running with PM2 across crashes and reboots, and serve it through Nginx with HTTPS.

  • Intermediate
  • Linux VPS
  • 3 min read

Linux VPS

Create an SFTP-only user limited to one folder

Give someone file access over SFTP without a shell, locked inside one folder. Configure internal-sftp with a Match block, set the chroot ownership right and test with WinSCP.

  • Advanced
  • Linux VPS
  • 5 min read