#911 closed defect (fixed)
Configuring the setclock Script: "hwclock --show" always shows localtime
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | lowest | Milestone: | |
Component: | Book | Version: | TESTING |
Severity: | normal | Keywords: | |
Cc: |
Description
Chapter 7, "Configuring the setclock Script", says the following: "If you cannot remember whether or not the hardware clock is set to UTC time, find out by running the hwclock --show command. This will tell what the current time is according to the hardware clock. If this time matches whatever your watch says, then the hardware clock is set to local time. If the output from hwclock is not local time, chances are it is set to UTC time. [...]" According to hwclock's man page, with the --show option, "The time shown is always in local time, even if you keep your Hardware Clock in Coordinated Universal Time" This way, the "hwclock --show" command will always show local time and does not help finding whether hardware clock is set to UTC or localtime. The command that does exactly what the LFS book intends to say is "hwclock --localtime --show", which shows the localtime if hw clock is set to localtime, or UTC otherwise. This works because, I suppose, "--localtime" means "show the 'raw' clock (as seen on the BIOS setup)".
Change History (4)
comment:1 by , 20 years ago
comment:2 by , 20 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 20 years ago
Now that is interesting. This from an LFS-6 system:
gerard@garion~$ date Thu Sep 30 14:51:06 MDT 2004
root@garion/home/gerard# hwclock Thu Sep 30 20:51:15 2004 -0.709593 seconds root@garion/home/gerard# hwclock --show Thu Sep 30 20:51:17 2004 -0.225091 seconds root@garion/home/gerard# hwclock --show --localtime Thu Sep 30 20:51:26 2004 -0.836470 seconds
All three options show the UTC time as it's in the BIOS.
comment:4 by , 20 years ago
I think I just found why: hwclock seems to react differently if the TZ env variable is set or not. Try these commands instead: TZ=Canada/Mountain hwclock --localtime --show TZ=Canada/Mountain hwclock --show (guessing your timezone here.) Anyway, "hwclock --localtime --show" seems to show the correct "BIOS time" don't matter TZ is set or not. Matthew, can you confirm the system you tested had TZ set?
Confirmed - here's the output of my box whose BIOS is set to UTC:
-su-3.00# hwclock --show Tue 28 Sep 2004 15:36:48 BST -0.216012 seconds -su-3.00# hwclock --localtime --show Tue 28 Sep 2004 14:37:01 BST -0.332687 seconds