Skip to content
Snippets Groups Projects
Commit 9e794f64 authored by Andreas Henriksson's avatar Andreas Henriksson
Browse files

hwclock-set: use both systz and hctosys

Ben Hutchings wrote:

If you use NTP and tell the kernel to adjust the system time, that
causes the kernel to periodically write the system time to the RTC too,
because the system time will be more accurate.

For hysterical raisins, the first call to settimeofday() that specifies
a 'time zone' (local time offset) implicitly sets whether the RTC is
supposed to hold local time or UTC: if the time value is unspecified and
the time offset is non-zero then the RTC holds local time, otherwise it
holds UTC.  There is no way to change this later!

'hwclock --hctosys' specifies both time value and time offset, and
therefore implicitly configures the RTC to hold UTC (but only when NTP
is used and it is written periodically by the kernel).

So we absolutely have to run 'hwclock --systz' first.  We could *also*
run 'hwclock --hctosys' straight after that.

Closes: #764552
Thanks: Ben Hutchings for debugging this.
parent 3d21d316
No related branches found
No related tags found
No related merge requests found
......@@ -26,8 +26,10 @@ if [ -f /etc/default/hwclock ] ; then
fi
if [ yes = "$BADYEAR" ] ; then
/sbin/hwclock --rtc=$dev --systz --badyear
/sbin/hwclock --rtc=$dev --hctosys --badyear
else
/sbin/hwclock --rtc=$dev --systz
/sbin/hwclock --rtc=$dev --hctosys
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment