Two things (related):
0) SETCLOCK cannot interpret linuxconf-written value
System: RedHat 6.0 2.2.12-29.4 (actually a VALinux RedHat)
on an Intel board
written by linuxconf. setclock did NOT understand this
(did not see I wanted UTC in the hardware clock). I had to change
...which solved the problem.
1) SETCLOCK/HWCLOCK cannot see I want UTC
System: RedHat 6.2 2.2.14-5 (directly from freshly bought RedHat CD)
on an Intel board (...old one)
setclock does not seem to consider /etc/sysconfig/clock correctly.
I'm running system clock in local time (UTC+2).
This has been freshly written by linuxconf.
I want the hardware clock to run in UTC, so I do: 'setclock'
The hwclock stays in local time! Tried 'UTC=true' in the
/etc/sysconfig/clock, which did not work
either. Tried 'hwclock --utc --systohc', which did not work either.
Even 'hwclock --set --utc --date="`date -u`"' does not work.
Checked with success whether hwclock can set the date at all.
Problem is circumvented by doing a 'hwclock --set --date="<date>"
with <date> the UTC date.
Retested the case under newly installed RedHat7.0
on the same machine; the problem is still there:
Mon Feb 26 17:02:29 CET 2001
Mon Feb 26 16:02:29 UTC 2001
Mon Feb 26 17:02:30 2001 0.306271 seconds
Full backpedal -- it's case closed, Watson. At least for the RedHat 7.0
system. I will come back with results of the 6.2 soon, just have to swap the
So, it actually works as expected and I didn't realize it. Sorry
for the trouble, people. I will do a hundred push-ups as penance. Here's the
- date <localtime> (sets the system clock)
- setclock (sets the hardware clock from the system clock. localtime
is converted to UTC if /etc/sysconfig/clock says so)
Alternatively, one can use the hardwareclock first, the systemclock second:
- hwclock --set --utc --date=<localtime>
This means: set the hwclock to the <locatime> and assume that the hwclock
should be in UTC.
- hwclock --hctosys --utc
This means: set the system clock from the hardware clock assuming the
hardware clock is in UTC; the timezone correction is made automagically.
We verify, being in timezone UTC+1:
- date;date -u;hwclock --utc;hwclock --localtime
Sat Feb 26 17:47:33 CET 2000 System clock localtime
Sat Feb 26 16:47:33 UTC 2000 System clock UTC
Sat Feb 26 17:47:34 2000 0.776101 s Hwclk in localtime if hwclock in UTC
Sat Feb 26 16:47:35 2000 0.975892 s Hwclk in localtime if hwclock in loctime
which is what we expect!