brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: timedatectl set-local-rtc 0 keeps the hardware clock in UTC

Hardware
~/tips/tip-linux-timedatectl-set-local-rtc-utc

timedatectl

Stops the clock from jumping an hour after reboots by storing hardware time in UTC.

A clock that is exactly one or two hours off after a reboot is rarely an NTP problem. In the Netherlands that number is a big hint: it matches our offset from UTC in winter and summer. The usual cause is the hardware clock being kept in local time.

A PC has two clocks: the system clock the kernel uses and the battery-backed hardware clock (RTC) that keeps time while the machine is off. Linux expects the RTC to run in UTC. Check what yours does:

timedatectl

Look at the last line, RTC in local TZ. If it says yes, the timedatectl manual is pretty blunt about it: keeping the RTC in local time is not fully supported and causes problems with time zone changes and daylight saving. With two clock changes a year here, that’s exactly where it bites. Switch it back:

sudo timedatectl set-local-rtc 0

This writes the setting to the third line of /etc/adjtime and then sets the RTC from the system clock, so the system time you have now is what gets stored. If the system clock is the wrong one, fix that first, or add --adjust-system-clock to do it the other way around and set the system clock from the RTC.

The caveat is another operating system on the same machine that expects local time in the RTC. Both will fight over the same clock, and you’ll have to tell that other system to use UTC as well. On a server that only runs Linux, I’d simply always use 0.

Further reading: timedatectl(1) manual page, hwclock(8) manual page

More Hardware tips disable_poe_fan=1 sudo dmidecode -s bios-version sudo lshw -short rfkill list udevadm monitor All Hardware tips (8) All topics

Link