[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Mac mini: serious clock drift



Hi Bram, Hi All

Bram, I'm not an expert for time setting procedures on Linux. The
following is just a glimpse on what I might have learned on Linux time
setting routines over the last few years ...

On Fri, Mar 09 2007, at 16:00 +0100, Bram Senders wrote:
> On Fri, Mar 09, 2007 at 02:32:03PM +0100, Wolfgang Pfeiffer wrote:
> > On Thu, Mar 08 2007, at 16:04 +0100, Bram Senders wrote:
> > > I am having issues with clock drift on my G4 Mac mini.  
> > 
> > Before we go into further details:
> > 
> > You have until-linux installed, and you have /etc/init.d/hwclock.sh on
> > your system, do you?
> 
> Yes, I have hwclock.sh.  

That's what I assumed ... :)

> However, I usually leave my computer running all the time, 

I thought you'd do that ...

> and the only thing hwclock.sh does is load and save the system clock
> from/to the hardware clock on boot/shutdown, right?

Not quite. If you have the default hwclock.sh in /etc/init.d/, then it
does not simply set the Hardware clock to the value of the system clock
when you shutdown your machine, it also calculates the drift rate of
the Hardware clock via the --systohc option in hwclock.sh...

Excerpt from man hwclock:

------------------------------------
Every  time  you calibrate (set) the clock (using --set or --systohc ),
hwclock recalculates the systematic drift rate [ ... ]
----------------------------------------

So putting a --systohc to hwclock.sh is no problem, as long as your
system time is correct (It's probably never correct on any system, if
you leave your sys time alone more than some secs).

I have to guess in the following, as I do not know the details of what
ntpd is doing on your system (BTW: I don't have ntpd even installed
... :)

If I understand your first message in this thread, your sys time is
messed up very quickly . But when shutting down, hwclock thinks your
system time is correct; it then sets the Hardware clock to the value
of your system time (--systohc) *and* calculates the drift rate of the
Hardware clock according to that wrong system time. Which might be a
reason it's messed up more and more the more often you run that
routine via hwclock.sh ... 

'man hwclock' discusses this in great detail. This man page is certainly
one of the best I ever found on Linux. Especially have a look at the
part called "The Adjust Function".

Also, see 
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=263116
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=171281
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=97349

where David Lawyer, as I understand him, for years tried to explain
why the Debian hwclock.sh is messing up the time on computers running
Debian and their version of hwclock.sh.

So the cure seems to me:

*** 1: Understanding what 'man hwclock' says.

*** 2: Understanding what David Lawyer in the bug reports above is
       trying to explain.

*** 3: Having a look at the scripts/README in the attached tar ball.
       
*** 4: I'd suggest to stop ntpd. I does not seem to be necessary to me
       as long as one has 'ntpdate' and hwclock on a system. I'd try
       to keep things as simple as possible.

With the attached 2 scripts and the necessary changes in
/etc/init.d/hwclock.sh I have a sys time that gains about +20 secs in
about 4 months .. without the need of running some ntpd and without
the need to access some time server in these months to set the correct
system time. So yes: I didn't do anything, IIRC, in these 4 months
except just letting hwclock do its job. 

Note: 4 months without running tuneclock.sh (in the tarball) seems a
bit too long to me ... :)
 
Please check the scripts/README in the tar ball carefully. These
scripts are not ready for use: One has to change them according to
one's needs. And yes: I'm making mistakes. That is, the fact the
scripts work, doesn't mean they're right.

HTH

Best Regards
Wolfgang

PS: I don't PM this message to you, Bram, as the attachment seems to
make it a bit to heavy to receive it twice ....

-- 
Wolfgang Pfeiffer: /ICQ: 286585973/ + + +  /AIM: crashinglinux/
http://profiles.yahoo.com/wolfgangpfeiffer

I made slight changes on Key ID: E3037113. Please refresh it.
http://keyserver.mine.nu/pks/lookup?search=0xE3037113&fingerprint=on

Attachment: clock.calibrating.tar
Description: Time setting scripts


Reply to: