Bug 13290 - hwclock & setclock broken if UTC desired
Summary: hwclock & setclock broken if UTC desired
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: util-linux
Version: 6.2
Hardware: i586
OS: Linux
medium
low
Target Milestone: ---
Assignee: Erik Troan
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-06-30 19:37 UTC by david.to
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-02-26 17:30:07 UTC
Embargoed:


Attachments (Terms of Use)

Description david.to 2000-06-30 19:37:56 UTC
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
   /etc/sysconfig/clock contained:
   ZONE="Europe/Luxembourg"
   UTC="yes"
   ARC=false
   written by linuxconf. setclock did NOT understand this
   (did not see I wanted UTC in the hardware clock). I had to change
   the file:
   ZONE="Europe/Luxembourg"
   UTC=true
   ARC=false
   ...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).
   /etc/sysconfig/clock says:
   ZONE="Europe/Luxembourg"
   UTC="yes"
   ARC=false
   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.

Comment 1 David Tonhofer 2001-02-26 16:03:28 UTC
Retested the case under newly installed RedHat7.0
on the same machine; the problem is still there:

/etc/sysconfig/clock says:

   ZONE="Europe/Luxembourg"
   UTC=true
   ARC=false

I do:

   date 022616462001.50
   setclock
   date;date -u;hwclock

 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


Comment 2 David Tonhofer 2001-02-26 17:30:03 UTC
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
harddisks.

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
recipe:

 - 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!




Note You need to log in before you can comment on or make changes to this bug.