Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem with iBook clock, with Gentoo and MacOSX
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
strider2003
Apprentice
Apprentice


Joined: 14 Sep 2003
Posts: 151
Location: Spain

PostPosted: Tue Nov 23, 2004 9:34 pm    Post subject: Problem with iBook clock, with Gentoo and MacOSX Reply with quote

I have an iBook G4 with Gentoo and MacOSX.
I haven't been able to find a way to keep the same, correct time in both OS. I have read several posts about this subject in this forum, but none of them works for me (maybe I'm doing something wrong).
Could any of you explain, step by step, what should I do to synchronize both clocks with the correct time?
Before someone suggests using ntp, I don't want to use this option because the iBook is not always online.

Thank you all.
Back to top
View user's profile Send private message
gnomeza
Tux's lil' helper
Tux's lil' helper


Joined: 31 Dec 2003
Posts: 97

PostPosted: Wed Nov 24, 2004 12:36 pm    Post subject: Syncing clocks between Gentoo and OSX Reply with quote

The very essentials
As long as:

  1. Your Hardware Clock is set correctly to UTC, and
  2. your /etc/adjtime file in Gentoo is zeroed or does not exist,

your time will be correct in both Gentoo and OSX.


The short answer

Code:
echo "0.0 0 0.0" > /etc/adjtime
/sbin/hwclock --utc  --set --date="MMDDhhmm[YY].ss"
/sbin/reboot


The explanation

  1. Set the clock drift tracking file to zero drift.
  2. Set the hwclock in UTC form (as OSX does) to the specified date/time.
    The argument to the --date option must be local time. It is passed to the date(1) program.
  3. Reboot. On startup the system clock will be synced with the (correctly set) hardware clock. It is considered unsafe to set the system clock while the system is running.


If you don't want to reboot and you're happy to accept the risks you can do the following instead of /sbin/reboot:
Code:
/sbin/hwclock --hctosys --utc


Which sets the system clock to the hardware clock.
Saves you rebooting, but may screw up some running programs...

The long explanation

OSX stores the time in UTC form so when you set the hwclock in Linux make sure you specify --utc.

There are two clocks to worry about. The Hardware Clock and the System Clock. Read the NOTES section of man 8 hwclock for details.

Hardware clocks aren't accurate, but drift in a predictable manner, so Linux tracks the drift by calculating how much the clock is adjusted each time the hardware clock is set (by the user). In Gentoo this drift is stored in the file /etc/adjtime

On startup ( /etc/init.d/clock ), Gentoo checks if /etc/adjtime exists. If so, it adjusts the hardware clock by the drift amount and sets the system clock to the hardware clock. ( /sbin/hwclock --adjust --hctosys )

So if your problem was:

  1. OSX time correct, Gentoo time incorrect
    What's probably happening with your system is that by playing with the hwclock, you've accumulated a large drift in /etc/adjtime. So Linux thinks your hwclock is wildly inaccurate and "corrects" it on startup...
  2. OSX incorrect, Gentoo correct
    In Gentoo you've probably set the hwclock in localtime, rather than UTC. OSX expects the Hardware Clock to be in UTC.
  3. OSX incorrect, Gentoo incorrect
    A combination of (1) and (2) above


References
man 8 hwclock
/etc/init.d/clock



Hope this helps!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC 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