Time/TimeZone set

I just installed OpenSuse 11.2 3 months ago on my laptop. I’m running with the Gnome Desktop. I live in Chicago and am currently in London. When I set the timezone to Europe/UK the date/time are correct UNTIL I reboot the laptop. After reboot if I type in the ‘date’ command it shows the time at 6+ hours from London time. When I check the hardware clock ‘hwclock’ it displays the correct London time. I check the time setup with yast and it shows the correct Timezone but again shows the 6+ hours difference. I change the time in yast and and my applications ( e-mail) display the correct local time again… UNTIL I reboot and then I’m right back where I started - wrong local time ! I suppose I could write a little startup script to do a ‘hwclock --hctosys’ but I thought I’d check here first to see if anyone out there had any ideas…
BTW - I hate to say this but on the same laptop running XP I don’t have this problem AND I didn’t see this problem in OpenSuse 10.3 or 11.1
Thanks…
Jim

When you shutdown the machine, the portion of /etc/init.d/boot.clock that writes the time back to the hardware clock is this:

        if test "$ELEVENMIN_MODE" = yes ; then
            echo "The System Time is in sync with Hardware Clock ${stat}${done}good${norm}"
            rc_status
            rc_exit
        fi
        if test "$USE_HWCLOCK" = yes -a "$SYSTOHC" = yes ; then
            echo -n "Set Hardware Clock to the current System Time"
            #
            # Write system time back to hardware clock
            #
            if test "$USE_ADJFILE" = yes ; then
                /sbin/hwclock --systohc $HWCLOCK
            else
                # Remove any /etc/adjtime left over
                test -e /etc/adjtime && rm -f /etc/adjtime
                /sbin/hwclock --systohc $HWCLOCK --noadjfile
            fi
            rc_status -v
        fi
        ;;

So you should watch the shutdown messages to see if it displays:

Set Hardware Clock to the current System Time

If not, then check your settings for USE_HWCLOCK and SYSTOHC in /etc/sysconfig/clock.

Ok time is complicated.

  1. If you originally had the Hardware set to UTC (btw London or Greenwich time) then you had the OS told the HW clock was UTC not local so you should just need to change the timezone of the OS clock

  2. If you originally had the HW clock set to the local time and the OS was set to local. Changing the HW clock should do it.

  3. If you are dual booting then Windows figures in. Windows sets the HW clock to local time. So you must have the Linux clock set to use local. And be sure that the time zones are set right

There is easily several more possibilities when you throw in time servers.

Well one thinks for sure … boot.clock isn’t working correctly …

date

Sat Feb 27 01:34:17 GMT 2010

hwclock

Fri Feb 26 19:34:29 2010 -0.642278 seconds

service boot.clock start

Set System Time to the current Hardware Clock Fri Feb 26 19:36:05 2010 -0.235004 seconds

date

Sat Feb 27 01:37:41 GMT 2010

hwclock --hctosys

date

Fri Feb 26 19:38:55 GMT 2010

Think I’m going to write my own boot script and scrap boot.clock

Thanks for the response ! It put me off in the right direction !
Cheers !
Jim

It looks like you are running the hardware clock in local time, rather than UTC. If so, you should add the option -u to hwclock to display or set the right time.

Also if you are not dual booting the machine with the Redmond OS, you should set hardware clock to UTC.

You should understand the interactions between localtime, UTC and hardware clock before concluding that the boot script is wrong.

O.K. - Fair enough …

date

Sat Feb 27 06:27:53 GMT 2010

hwclock -u

Sat Feb 27 00:29:28 2010 -0.126645 seconds

service boot.clock start

Set System Time to the current Hardware Clock

date

Sat Feb 27 06:40:48 GMT 2010

hwclock -u

Sat Feb 27 00:30:52 2010 -0.599809 seconds

Pertinent parts of /etc/sysconfig/clock

HWCLOCK="-u"
SYSTOHC=“yes”
TIMEZONE=“Europe/London”
DEFAULT_TIMEZONE=“US/Central”

BTW - the comments in /etc/sysconfig/clock mention a /usr/lib/zoneinfo
I see no such file or directory

I will make no more assumptions about things being broken…I will leave that to those who do understand the interactions between localtime, UTC and hardware clock – I’ll only report what I see …

Cheers
Jim

That comment is out of date, and this could be considered a trivial bug. The directory is /usr/share/zoneinfo.

But you still haven’t answered the real question before you went on this diversion, do you get the message

Set Hardware Clock to the current System Time

at shutdown, presumably after you have changed the timezone while the machine was up. That’s the part that writes the time back to the hwclock.

And anyway, if you are running the hwclock in UTC as the -u implies, then the hwclock should be at the correct time no matter what the timezone, and this writeback won’t matter.

But from what you report, it looks like the hwclock is already at the wrong time, because it should report localtime. You should fix it with

hwclock --systohc -u

after checking that the system time is correct.

But Windows sets it to local time. But because you are in London and presumably have set your time zone to same you are now at UTC +0. And this is now your local time. You need to see what Yast thinks is happening. Yast-System-Date & Time, Make sure the UTC box is NOT checked. Be Sure the time zone reflects your current zone and be sure the time is then set to the correct local time/date. Save it

Then in th GUI clock be sure that the zone is correct and matches the zone set in Yast

That should do it. It is infinitely easier without Windows in the mix. You simply set the HW to UTC and move the time zones as needed.

Well, that’s the other question he didn’t answer, because we don’t really know if he dual boots. However he uses UTC in Linux as the -u in /etc/sysconfig/clock shows. If he is using Windows, then that wouldn’t work, Windows and Linux would be constantly resetting the hwclock their way and cause that kind of symptom.

His “by the way remark” at the bottom says he is running XP on the same hardware so I assume he is dual booting.

Ah ok missed that. Your’s is the correct fix then. For anybody happening on this thread in future: You cannot use Hardware clock in UTC when dual booting with Windows.

Correct – I am dual booted though I seldom use XP… I use Linux at work…

So I have done as you suggested and unchecked UTC in yast so now /etc/sysconfig/clock pertinent bits are:

HWCLOCK="–localtime"
SYSTOHC=“yes”
TIMEZONE=“Europe/London”
DEFAULT_TIMEZONE=“US/Central”

After rebooting I now have:

date

Sat Feb 27 19:24:31 GMT 2010

hwclock -u

Sat Feb 27 13:25:16 2010 -0.407748 seconds

I’m back where I started …

Anyway – I can resolve my problem by syncing off an ntp server which makes the correct adjustment for the time zone and sets the system clock accordingly.
I’ll check this out further when I get home. I have another laptop with opensuse 11.2 that is not dual boot. Like you say it should be a simple matter of setting the hardware clock to UTC and setting the timezone correctly.

Thanks for the help and suggestions !!
Cheers!
Jim

If you have set the clock to localtime, then you do not use -u with hwclock, either to set or get the time.