Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 72System · Linux

How to set the time zone and sync the clock

Wrong time breaks more than you think: TLS certificates look invalid, Kerberos and SSO logins fail, logs from two servers can not be compared, cron jobs run at the wrong hour. This how-to sets the time zone, syncs the clock with chrony (NTP), checks how far off the clock is, and explains why many teams keep servers on UTC.

  • 5 Lessen
  • 6 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

72.1

The quick answer

timedatectl
timedatectl set-timezone Asia/Riyadh
dnf -y install chrony
systemctl enable --now chronyd
chronyc tracking | grep -E 'Reference|System time'

On Ubuntu: apt-get install -y chrony (the service is called chrony).

72.2

Step by step

  1. Look at the current state:
timedatectl
               Local time: Thu 2026-11-19 14:05:11 +03
           Universal time: Thu 2026-11-19 11:05:11 UTC
                Time zone: Asia/Riyadh (+03, +0300)
System clock synchronized: yes
              NTP service: active
  1. Set the time zone — find the exact name first:
timedatectl list-timezones | grep -E 'Riyadh|Amsterdam|Cairo'
timedatectl set-timezone Asia/Riyadh

Many teams set UTC on all servers (timedatectl set-timezone UTC): logs from all countries line up, and there is no daylight-saving jump. People's tools (Grafana, Kibana) then show local time.

  1. Sync the clock with chrony — use your company's NTP servers if you have them, otherwise a public pool:
/etc/chrony.conf (part)
server ntp1.example.com iburst
server ntp2.example.com iburst
pool 2.rhel.pool.ntp.org iburst
makestep 1.0 3
rtcsync

iburst = sync fast at start; makestep 1.0 3 = jump the clock if it is more than 1 s off (only in the first 3 updates), later adjust slowly.

systemctl restart chronyd
timedatectl set-ntp true
  1. Check the sources and the offset:
chronyc sources -v
chronyc tracking
Reference ID    : C0000201 (ntp1.example.com)
System time     : 0.000012345 seconds fast of NTP time
Leap status     : Normal

^* in chronyc sources marks the server the clock follows now.

  1. Only one time service: on Ubuntu, systemd-timesyncd and chrony should not run together — installing chrony replaces it. Check: systemctl status systemd-timesyncd.
  2. Firewalls: NTP uses UDP 123 outbound. In the cloud, use the provider's time source: on AWS server 169.254.169.123 prefer iburst; Azure images already sync with the host clock — keep their chrony settings.

72.3

Check that it worked

timedatectl shows the right zone and System clock synchronized: yes, chronyc tracking shows an offset of milliseconds or less, and the time in logs is the same on all servers.

72.4

Common problems

ProblemCauseFix
System clock synchronized: nochrony not running, or UDP 123 blocked.systemctl status chronyd; open outbound UDP 123; check chronyc sources.
chronyc sources shows ? or xServer unreachable or judged wrong.Other servers; check DNS and the firewall.
Clock jumped back and an app brokeA big step correction.Fix big offsets at boot (makestep in first updates only); monitor the offset.
Cron jobs at the wrong hourTime zone changed but cron not restarted.systemctl restart crond (or reboot).
TLS: certificate is not yet validClock is behind.Sync the clock — check date first.
A VM's clock drifts a lotThe VM was paused or the host is busy.chrony with makestep; in VMware/Hyper-V turn off double time sync.

72.5

Go further

1In chronyc sources, what does ^* mean?

That is the time server the clock follows right now.

2Why do many teams keep servers on UTC?

Logs from all servers line up, and there is no daylight-saving jump.

Alle commando's in dit hoofdstuk