Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Clock desync after shutdown/startup
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Gentist
Apprentice
Apprentice


Joined: 20 Mar 2004
Posts: 247

PostPosted: Fri Aug 20, 2004 8:27 am    Post subject: Clock desync after shutdown/startup Reply with quote

I've been having this odd problem lately, sometimes when I shutdown the computer and turn it back on the next day or so, the clock is completely wrong. Now, I decided to test this, and most of the time, the BIOS displays it correctly (when it doesn't, it's most likely due to the fact that I didn't bother setting it correctly before shutting down). I'm not using an NTP server, and I don't want to, as that's not really a fix to the problem.

It's like Gentoo doesn't grab the time from the CMOS correctly. If I remember correctly, this started when I updated portage and accidently (due to being tired) overwrote the rc.conf file, which changed my clock settings from "local" to "UTC". After booting up the next day, I noticed the clock was wrong and recalled doing an etc-update, so I switched back to local and changed the time. However, this problem is still happening and I'm out of ideas... There doesn't seem to be any pattern to the time changes, although the date seem to be unaffected.
Back to top
View user's profile Send private message
Cuardin
l33t
l33t


Joined: 06 Feb 2003
Posts: 713
Location: vasastaden.stockholm.se

PostPosted: Fri Aug 20, 2004 8:31 am    Post subject: Reply with quote

Do you dual-boot? And how is you battery? If the battery is getting old I suppose it could cause the clock behave.

What is your reason for not wanting to use ntp? Nowadays there are actualy some tutorials that make sense regarding how to set it up.
_________________
Part of "The adopt an unanswered post initiative"
Back to top
View user's profile Send private message
Gentist
Apprentice
Apprentice


Joined: 20 Mar 2004
Posts: 247

PostPosted: Fri Aug 20, 2004 8:43 am    Post subject: Reply with quote

This machine is pure Gentoo, no dualboot.

Battery _should_ be fine (computer is only about 2 years old). As I said, the BIOS thingy seem to show the time correctly, but it's desynced once I start Gentoo. If the battery would start to fail, the CMOS would be resetted, along with the time and date, correct?

My reason for not wanting to use NTP is that I don't have the need to keep my clock exactly on time (in fact, I tend to set it a few mins ahead, just so that I won't be late for stuff). Also, I don't like being dependent on a server.
Back to top
View user's profile Send private message
Cuardin
l33t
l33t


Joined: 06 Feb 2003
Posts: 713
Location: vasastaden.stockholm.se

PostPosted: Fri Aug 20, 2004 8:56 am    Post subject: Reply with quote

So there is obviously a problem when your system clock is updated from the bios clock. That is beyond my level.
_________________
Part of "The adopt an unanswered post initiative"
Back to top
View user's profile Send private message
Gentist
Apprentice
Apprentice


Joined: 20 Mar 2004
Posts: 247

PostPosted: Fri Aug 20, 2004 9:10 am    Post subject: Reply with quote

Cuardin wrote:
So there is obviously a problem when your system clock is updated from the bios clock.

That's what it looks like, however, I have no idea if it's some hardware malfunction, or something in Gentoo not doing what it's supposed to, or something doing something it shouldn't (virus?).

Anyone out there with more insight that might know what the problem is (I.E. Gentoo developer)?
Back to top
View user's profile Send private message
rtn
Guru
Guru


Joined: 15 Nov 2002
Posts: 427

PostPosted: Fri Aug 20, 2004 4:50 pm    Post subject: Reply with quote

You can use /sbin/hwclock to fix the time -- either set the CMOS time to
the linux time as returned by `date` or vice versa.

Instead of running ntp to sync your time, it might not be a bad idea just
to run ntpdate in your boot sequence. If you need a bit more precision,
you could run ntpdate via cron once per day/week/whatever.

--rtn
Back to top
View user's profile Send private message
Gentist
Apprentice
Apprentice


Joined: 20 Mar 2004
Posts: 247

PostPosted: Fri Aug 20, 2004 8:21 pm    Post subject: Reply with quote

rtn wrote:
You can use /sbin/hwclock to fix the time -- either set the CMOS time to
the linux time as returned by `date` or vice versa.


I set the time using hwclock... (hwclock --systohc) Let's see if it helps. (I'll notice in a few days)

rtn wrote:

Instead of running ntp to sync your time, it might not be a bad idea just
to run ntpdate in your boot sequence. If you need a bit more precision,
you could run ntpdate via cron once per day/week/whatever.

--rtn

Hmm... Might do that sometime. Linux doesn't deal too well with daylight saving stuff, right?
Back to top
View user's profile Send private message
rtn
Guru
Guru


Joined: 15 Nov 2002
Posts: 427

PostPosted: Fri Aug 20, 2004 8:26 pm    Post subject: Reply with quote

Gentist wrote:
Hmm... Might do that sometime. Linux doesn't deal too well with daylight saving stuff, right?


As long as your timezone is set properly, you shouldn't have a problem.

--rtn
Back to top
View user's profile Send private message
Cuardin
l33t
l33t


Joined: 06 Feb 2003
Posts: 713
Location: vasastaden.stockholm.se

PostPosted: Fri Aug 20, 2004 8:45 pm    Post subject: Reply with quote

Only gets you into a mess when m$ programs try to adjust it for you.
_________________
Part of "The adopt an unanswered post initiative"
Back to top
View user's profile Send private message
tomchuk
Guru
Guru


Joined: 23 Mar 2003
Posts: 317
Location: Brooklyn, NY

PostPosted: Sat Aug 21, 2004 4:20 am    Post subject: Reply with quote

rtn wrote:

Instead of running ntp to sync your time, it might not be a bad idea just
to run ntpdate in your boot sequence.

Yes, a "ntpdate pool.ntp.org && hwclock --systohc" in /etc/conf.d/local.start is a good idea in your case.

Quote:
If you need a bit more precision,
you could run ntpdate via cron once per day/week/whatever.
--rtn


Not really a good idea. People who maintain ntp servers are having big problems getting hammered every hour on the hour by people who set rdate, ntpdate, netdate, etc from cron jobs. ntpd updates randomly and is much more efficent than ntpdate. Also ntpdate doesn't address the real issue which is clock drift. ntpd tracks clock drift and can adjust your clock even if it can't contact a time server.

My laptop has been up for 5 days and ntpd has only used 9 seconds of CPU time not exactly anything you'd notice. If you install ntpd, grab the config file from /usr/share/ntp rather than the default /etc/ntp.conf as it is better commented and uses the pool.ntp.org round-robin server for updates.
Back to top
View user's profile Send private message
bludger
Guru
Guru


Joined: 09 Apr 2003
Posts: 389

PostPosted: Tue Sep 28, 2004 9:58 am    Post subject: Reply with quote

Gentist wrote:
Hmm... Might do that sometime. Linux doesn't deal too well with daylight saving stuff, right?


Actually Linux deals very well with daylight saving stuff. It is MUCH cleaner than windows. If you put CLOCK="UTC" in your /etc/rc.conf file and setup your /etc/localtime link to point to your timezone file, your linux box will handle time very cleanly. Basically the internal clock will stay set to UTC and will never need to be changed even during DST transitions, all that will change is the local time offset displayed by your applications. If you have an up-to-date system, they should display the correct local time with the correct DST transition dates.

Windows, on the other hand, actually changes the system clock during DST transitions. This can break a lot of things when the time is set back an hour.
Back to top
View user's profile Send private message
bludger
Guru
Guru


Joined: 09 Apr 2003
Posts: 389

PostPosted: Tue Sep 28, 2004 10:03 am    Post subject: Reply with quote

Gentist wrote:
Cuardin wrote:
So there is obviously a problem when your system clock is updated from the bios clock.

That's what it looks like, however, I have no idea if it's some hardware malfunction, or something in Gentoo not doing what it's supposed to, or something doing something it shouldn't (virus?).

Anyone out there with more insight that might know what the problem is (I.E. Gentoo developer)?


I have a system that is also messing the time up after it has been shutdown for some time. It is a fairly old box, so it could be the CMOS battery. The hw clock is set and read by the /etc/init.d/clock script. Maybe I will edit the script to write the system and hw time to a log before and after hwclock sets the time on both startup and shutdown, then I should be able to see more clearly what is happening.
Back to top
View user's profile Send private message
big_toys
n00b
n00b


Joined: 19 Sep 2004
Posts: 2

PostPosted: Sat Oct 02, 2004 1:26 pm    Post subject: Reply with quote

I had the same problem with the clock resetting by strange offsets at boot time. I traced the problem to weird values in /etc/adjtime, which probably manifested after I made some changes to the system, including changing the time zone, changing the hardware clock to local (due to dual booting with Windows) and adding ntpd.

To fix the problem, I did the following:

After verifying that date returned the correct time, I synced the hardware clock with _

Code:
$ hwclock --systohc


I deleted /etc/adjtime ($ rm /etc/adjtime), which the initialization script /etc/init.d/clock reset with zero offsets on the next start.

Since ntpd will handle any necessary clock adjustments, it doesn't concern the initialization script anymore. Therefore, I made the following changes in /etc/init.d/clock, so that it doesn't adjust the hardware clock at every start and possibly cause problems by interfering with ntpd:
Code:
       
#errstr="$(/sbin/hwclock --adjust ${myopts} 2>&1 >/dev/null)"
#errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"
errstr="$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"


Try cat /etc/adjtime. If the first and third numbers of the first line show anything other than zero, this will most likely explain your problems. Delete /etc/adjtime _

Code:
$ rm /etc/adjtime


Then set your clock with date, rdate, ntpdate, etc, according to your preference, and sync your hardware clock with _

Code:
$ hwclock --systohc


Edit: If you have your hardware clock set to CLOCK="UTC" instead of CLOCK="local" (in /etc/rc.conf), if I understand it correctly (correct me if I'm wrong), you would want to use _

Code:
$ hwclock --utc --systohc


If you have changed the system time, at this point you might want to reboot, to avoid any conflicts in running services which might depend on the system time:

Code:
$ reboot


If that doesn't fix it, I don't know what to tell you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum