Some tickets make no sense until you check the clock.
A customer reports the site is "insecure", but the certificate is valid. Another says a request was "rejected" at 14:00, yet the access log for 14:00 is empty. A cron job runs, then it doesn't. A token that should last an hour expires in minutes.
All of these can share one root cause: the server's clock is wrong. Clock drift is quiet. It never throws an error of its own. It only distorts every conclusion you draw after it.
The three layers of time
On a Linux server, "time" is really three separate things, and mixing them up is where most of the confusion comes from.
- The system clock — the kernel's idea of the current time. This is what NTP keeps honest.
- The time zone — which region the machine thinks it lives in. This decides what clock the logs write.
- The application time zone — PHP, MySQL, and Java each keep their own. A mis-set application timezone shows the same operation at two different clock times in the same log.
A clock that is off by a few hours can be a timezone problem, a drift problem, or both. The fix is different in each case.
Step 1: Capture evidence before you touch anything
The worst thing you can do is change the clock first. After that, the ticket becomes "time was weird, then we changed it," which helps nobody.
timedatectl date -u date -u timedatectl show -p Timezone -p NTPSynchronized -p NTP timedatectl date shows the current local time, the UTC time, and whether the clock is synchronized. date -u gives the UTC time alone. Write down the offset before you change anything.
Step 2: Is the clock actually synchronized?
Look at two lines in timedatectl:
-
System clock synchronized: yes— the clock is being corrected. -
NTP service: active— the sync daemon is running.
Either one reading "no" or "inactive" is a reason to keep digging. A service can be active and still be unable to reach a time source, so these two lines are a starting point, not proof.
Step 3: Which daemon is doing the work
systemctl status systemd-timesyncd --no-pager systemctl status chronyd --no-pager Modern distributions ship either systemd-timesyncd or chrony. They do the same job differently. Running both at once is a common mistake — pick one.
Step 4: Look at the offset, not the status
A green service status does not mean the clock is right. The offset is what matters.
chronyc tracking chronyc sources -v chronyc tracking shows System time, the current offset in seconds. In a healthy setup this is a small decimal. If it is hundreds of milliseconds or more, the machine is not actually locked to a source.
chronyc sources -v lists the upstream servers. A line with ^* is the source currently being used. A line with ? or x means the upstream is unreachable or rejected — that is the clue that the firewall or the network, not the config, is the problem.
Step 5: Fix it
If NTP service is inactive, start it:
sudo timedatectl set-ntp true On systems that use chrony:
sudo dnf install chrony # or: sudo apt install chrony sudo systemctl enable --now chronyd Add a reliable pool to /etc/chrony.conf:
server 0.pool.ntp.org iburst Then restart the service. Do not enable chronyd and systemd-timesyncd at the same time.
Step 6: A large offset needs a step, not a slew
NTP corrects small errors gradually, which is called slewing. A big error — a machine left off for weeks, or restored from a snapshot — is usually corrected in one step. The default chrony setting is makestep 1.0 3, which means it will step the clock if the offset is larger than one second, but only during the first three corrections after the service starts. After that it falls back to slewing.
If the offset is large and you need it corrected now:
sudo chronyc makestep Manual date -s is the last resort. It does not fix the reason the clock drifted, and a sudden backward jump can confuse databases and message queues. Coordinate large changes with the application owners.
Step 7: Write it back to the hardware clock
The kernel clock is corrected, but the battery-backed hardware clock may still be old. On reboot the machine reads the hardware clock and gets dragged back to the wrong time.
sudo hwclock --systohc This step is easy to skip, and skipping it is why the clock "comes back wrong" after every restart.
Step 8: UDP 123
NTP uses UDP port 123. Many cloud security groups block it by default, and the sync fails silently. If the sources show ? or x but the pool is correctly configured, check the firewall:
sudo firewall-cmd --add-service=ntp --permanent sudo firewall-cmd --reload The special cases
- Containers. A container shares the host kernel clock, so
date -sinside it will fail. The real fix is on the host. The timezone, however, comes from the image, so a container can show a different clock time than the host even when both are correct. - Virtual machines. VMware hosts need
vmware-toolbox-cmd timesync enable. Hyper-V guests need time synchronization enabled in the integration services. Otherwise the host and guest can pull each other's clock back and forth. - The RTC battery. If the clock is wrong again after every power-off, check the motherboard battery. A CR2032 below about 2.6 V is a common physical cause, and no amount of NTP config fixes a dead battery.
Map the symptom to the cause
Once the clock is right, the symptoms explain themselves:
- Certificate says "not yet valid". The client's clock is behind. A valid certificate looks like it has not started yet.
- Certificate says "expired". The clock is ahead. A certificate that is still within its window looks finished.
- Logs out of order. If the offset is a fixed number of hours, suspect the timezone. If events jumble back and forth, suspect drift or a manual
date -s. - Cron runs late, early, or not at all. Cron reads the system clock. A machine that is a few minutes slow shifts every job by the same amount.
- Authentication fails. Kerberos and token-based systems reject requests when the client and server differ by more than a small window. The password can be right and the clock still wrong.
- Package and API errors. Signed repository metadata, session cookies, and distributed coordination all depend on timestamps.
The rule
Before you replace a certificate, before you reinstall the machine, before you declare "the server is fine" — check the clock. It costs one command, and it prevents you from fixing the wrong thing for an hour.
These are the checks worth running first on a time-related ticket. The wider set of field notes lives at jiunotes.top/en, and the same troubleshooting steps are gathered in the operations journal at ops.jiunotes.top.


