You are not logged in.

#1 2010-07-27 01:31:06

ktkhuong
Member
From: Houston, TX
Registered: 2008-03-18
Posts: 12

hwclock turns back time on shutdown

Hello Archers,

Thanks to the excellent wiki, I've successfully installed Arch on three machines so far without having to consult the forums. Now I have a strange problem that's popped up after I tried optimizing the startup and shutdown scripts. This is on a dual-boot system using localtime.

After I start Windows and sync the time, on reboot Arch displays the correct time. (So, the rc.sysinit script is good.) If I then reboot from Arch, however, the hardware clock in the BIOS gets turned back five hours. I've traced the problem to the following line in the rc.shutdown script by inserting "hwclock -r" before and after it:

/sbin/hwclock --systohc --localtime

What's odd is that this command is executed correctly if I issue it from a terminal before shutdown. Moreover, this exact same script (I copied it over to make sure) worked just fine on another dual-boot machine also using localtime. I have tried deleting the adjtime file to no avail. Also, reverting back to the original script did not resolve the matter.

Thanks in advance for any advice.


K

Offline

#2 2010-07-27 01:46:36

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,785

Re: hwclock turns back time on shutdown

Gee, 5 hours.  Isn't that about how far texas is from GMT during daylight savings?

Windows uses local time and refuses to use GMT.  Arch defaults to GMT.

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime"
# USEDIRECTISA: use direct I/O requests instead of /dev/rtc for hwclock
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.utf8"
HARDWARECLOCK="UTC"
USEDIRECTISA="no"
TIMEZONE="America/Los_Angeles"
KEYMAP="us"
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

The above is an excerpt from my /etc/rc.conf.

You might check to see if you changed HARDWARECLOCK to 'localtime'


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2010-07-27 03:08:50

ktkhuong
Member
From: Houston, TX
Registered: 2008-03-18
Posts: 12

Re: hwclock turns back time on shutdown

Yes, HARDWARECLOCK is set to "localtime". I meant to say that hwclock turns back five hours on every shutdown, not that it lags Windows by five hours. The time displayed by Windows is the same.


K

Offline

#4 2010-07-27 03:42:41

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,785

Re: hwclock turns back time on shutdown

The time displayed by Windows is the same.

Got it
Can you check the TIMEZONE variable?  If you are using localtime, I think shutdown is the only place it should come into play.

The only timezone I found that seemed appropriate is US/Central

Edit : Continuing:

What's odd is that this command is executed correctly if I issue it from a terminal before shutdown.

Did you run that as root?

Last edited by ewaller (2010-07-27 03:46:33)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2010-07-27 18:39:44

ktkhuong
Member
From: Houston, TX
Registered: 2008-03-18
Posts: 12

Re: hwclock turns back time on shutdown

ewaller wrote:

Can you check the TIMEZONE variable?

Thanks for the tip; I've been using "America/Mexico_City" this whole time. Unfortunately, the problem still persists.

ewaller wrote:

Did you run that as root?

Indeed, otherwise it wouldn't run.


K

Offline

#6 2010-07-28 18:30:35

Proofrific
Member
Registered: 2008-01-05
Posts: 215

Re: hwclock turns back time on shutdown

Try running `hwclock -r` and `date` to make sure you're indeed using localtime.  They should be the same.

Are your other computers dual boot, too?

Offline

#7 2010-07-28 18:37:58

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: hwclock turns back time on shutdown

Proofrific wrote:

Try running `hwclock -r` and `date` to make sure you're indeed using localtime.  They should be the same.

Are your other computers dual boot, too?

+1
'date' should give you the timezone, check if it's the right one.

Offline

#8 2010-07-28 20:54:46

ktkhuong
Member
From: Houston, TX
Registered: 2008-03-18
Posts: 12

Re: hwclock turns back time on shutdown

Proofrific wrote:

Try running `hwclock -r` and `date` to make sure you're indeed using localtime.  They should be the same.

They both show up as UTC. They didn't match when I first went to check, but after I again synced the time in Windows, they do now (for now, anyway). It's not the correct UTC time, either, since the clock gets turned back on shutdown.

I've checked to make sure that the appropriate /usr/share/zoneinfo file is there.

Proofrific wrote:

Are your other computers dual boot, too?

One of them is, also using localtime, and works fine. The other is Arch-only and uses UTC (which, as an aside, I now can't get to display the local time instead of UTC).


K

Offline

#9 2010-07-28 21:09:07

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: hwclock turns back time on shutdown

My rc.conf

HARDWARECLOCK="localtime"
TIMEZONE="Europe/Warsaw"
[karol@black ~]$ date
śro, 28 lip 2010, 23:16:26 CEST
[karol@black ~]$ hwclock -r
śro, 28 lip 2010, 23:16:31  -0.501674 seconds

I didn't touch rc.* scripts and it's fine as it is.

If I'm reading this right, you have localtime, but you get UTC *but* it's not correct UTC time?

Offline

#10 2010-07-28 21:30:03

ktkhuong
Member
From: Houston, TX
Registered: 2008-03-18
Posts: 12

Re: hwclock turns back time on shutdown

karol wrote:

I didn't touch rc.* scripts and it's fine as it is.

I haven't done anything too drastic to these scripts (most of which is covered here), basically just getting rid of unnecessary blocks of code, a few variables, and if-else statements. The exact same scripts (minus a different hostname for rc.sysinit) worked for my other dual-boot system.

karol wrote:

If I'm reading this right, you have localtime, but you get UTC *but* it's not correct UTC time?

Right, and the more times I power off, the worse it gets.


K

Offline

#11 2010-07-28 21:33:50

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: hwclock turns back time on shutdown

> Right, and the more times I power off, the worse it gets.
A time machine! tongue

> The exact same scripts (minus a different hostname for rc.sysinit) worked for my other dual-boot system.
That's the weird part.


I smell a fresh pie. I am just going AFK and may be some time tongue

Offline

#12 2010-07-28 21:44:18

ktkhuong
Member
From: Houston, TX
Registered: 2008-03-18
Posts: 12

Re: hwclock turns back time on shutdown

I suspect it's not the scripts per se, but something the scripts depend on (not rc.conf, I don't think).

karol wrote:

I smell a fresh pie. I am just going AFK and may be some time tongue

Enjoy, and thanks for stopping by. smile


K

Offline

Board footer

Powered by FluxBB