Fix time and timezone problems in logs
When to use this: Events from different devices do not line up, or logs show the wrong hour.
Before you start
Steps
-
Check the server's clock and sync status
terminaltimedatectl chronyc trackingSystem clock synchronized: yesis what you want. Ifchronycis missing:sudo apt install -y chrony. -
Pick a single timezone policy
terminalsudo timedatectl set-timezone UTCMany teams store logs in UTC and convert when reading. Choose one rule and use it on server and devices.
-
Sync the senders
On the FortiGate set NTP (System, Settings, NTP) and the correct timezone. On ESXi enable the NTP client. A device with a wrong clock stamps every line wrongly.
-
Compare arrival time to device time
terminalsudo tail -n 5 /var/log/remote/192.168.1.1/$(date +%Y-%m-%d).logIn the rsyslog config from this site each line starts with the server's arrival time, then the device's own message. A large gap between the two means the device clock is off.
How to verify it worked
- Arrival time and device time agree within a second or two.
Common errors and fixes
Q&A
Why do old syslog lines have no year or timezone?
The classic RFC 3164 timestamp has only month, day and time. The newer RFC 5424 uses an ISO timestamp with timezone.
Why log in UTC?
It avoids daylight-saving ambiguity and makes events from different regions comparable.