# clock problem

## xavier10

Hello,

I have an Albook 15". Below is my emerge info.

All was working correctly a few days ago but now, I have a problem with the time. When I turn my computer on, the date takes the last value it took under linux (time of my last shutdown). Everything is still working nice under MacOSX.

So, basically, I need to set the date again each time I start. My localtime info seems correct.

Did anyone experience this problem ?

```

$ emerge info

Portage 2.0.51-r14 (default-ppc-2004.1, gcc-3.4.1, glibc-2.3.3.20040420-r2, 2.6.9 ppc)

=================================================================

System uname: 2.6.9 ppc 7447/7457, altivec supported

Gentoo Base System version 1.4.16

Python:              dev-lang/python-2.3.3 [2.3.3 (#1, Jun 16 2004, 19:48:24)]

dev-lang/python:     2.3.3

sys-devel/autoconf:  2.59-r5

sys-devel/automake:  1.8.5-r1

sys-devel/binutils:  2.15.90.0.3-r3

sys-devel/libtool:   1.5.2-r7, 1.5.2-r5

virtual/os-headers:  2.4.22

ACCEPT_KEYWORDS="ppc"

AUTOCLEAN="no"

CFLAGS="-O2 -pipe -mcpu=7450 -maltivec -mabi=altivec"

CHOST="powerpc-unknown-linux-gnu"

CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"

CXXFLAGS="-O2 -pipe -mcpu=7450 -maltivec -mabi=altivec"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoaddcvs ccache distlocks"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/Linux/distributions/gentoo"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="X alsa berkdb cdr cups dvd esd f77 foomaticdb fortran gdbm gif gnome gnome-libs gpm gtk guile imlib jpeg kde libwww motif mozilla nls oggvorbis opengl pam perl png ppc ppds python qt readline sdl slang ssl tcltk tcpd tetex truetype usb"

Unset:  ASFLAGS, CBUILD, CTARGET, LDFLAGS, PORTDIR_OVERLAY

```

Xavier

----------

## BlueDog

I'm having the same problem.  The problem is with whatever kernel your using.  With some kernels it will work, with some it won't.  Unfortunately, most current kernels have this problem, and I don't know what the solution is.

----------

## xavier10

In my opinion it cannot be a problem with the kernel only, since I have not upgraded my kernel recently. I mean, I downloaded recent kernel sources via emerge but have not compiled a kernel for months. The problem appeared one week ago   :Shocked: 

I upgraded some packages recently, but unfortunately, I do not know about any "emerge logging" system (that would keep track about the recent emerges; this would be useful to find out when an upgrade breaks something). Alternatively, I should dump the output of the "emerge -puvD" command.

Xavier

----------

## lookinin

Hi there - as you all ready mentioned, verify your /etc/localtime symlink, and also check /etc/rc.conf, in which there is a CLOCK= setting that can be UTC or local.

----------

## xavier10

Just to say what my config is:

/etc/rc.conf:

```

CLOCK="UTC"

```

/etc/localtime:

```

lrwxr-xr-x  1 root root 32 Jan 17 04:48 /etc/localtime -> /usr/share/zoneinfo/Europe/Paris

```

Xavier

----------

## lookinin

 *xavier10 wrote:*   

> Just to say what my config is:
> 
> /etc/rc.conf:
> 
> ```
> ...

 

And if you try changing it to local?  Or did you all ready?

----------

## xavier10

No, I have not tried yet.

What does it change ? I usually see most people recommending setting it to "UTC"...

Xavier

----------

## lookinin

 *xavier10 wrote:*   

> No, I have not tried yet.
> 
> What does it change ? I usually see most people recommending setting it to "UTC"...
> 
> Xavier

 

It depends on how you want your BIOS clock to be set up.  If you want it to be set to UTC, gentoo will automatically adjust the clock to appear -/+ the appropriate amount for your timezone.  In other words, if your BIOS clock is set to your actual time, set this to be local.  I am not a guru or anything, just trying to help out a bit, so I'm sorry if I'm not giving better technical details.

If it were me, I'd try local - that's how mine is set, and I changed it to that  after I had a similar problem to yours.  It shouldn't hurt anything to test it, and you could always change it back  :Smile: 

----------

## xavier10

 *lookinin wrote:*   

> 
> 
> It depends on how you want your BIOS clock to be set up.  If you want it to be set to UTC, gentoo will automatically adjust the clock to appear -/+ the appropriate amount for your timezone.  In other words, if your BIOS clock is set to your actual time, set this to be local.  I am not a guru or anything, just trying to help out a bit, so I'm sorry if I'm not giving better technical details.
> 
> 

 

Ok, I understand better. Sorry for the additional question. I just happen to prefer understanding things before doing them  :Smile: 

 *Quote:*   

> 
> 
> If it were me, I'd try local - that's how mine is set, and I changed it to that  after I had a similar problem to yours.  It shouldn't hurt anything to test it, and you could always change it back 

 

I believe that I should try then, so I set it to local now. I will see at my next reboot if it works. Answer tomorrow morning.

Thank you very much for the information.

Xavier

----------

## xavier10

Ok, it has not worked  :Sad: 

When I started this morning, the time was the same as when I turned my laptop off yesterday.

Here is the line in my /etc/rc.conf file now:

```

CLOCK="local"

```

Another idea anyone ?

Xavier

----------

## lookinin

 *xavier10 wrote:*   

> Ok, it has not worked 
> 
> When I started this morning, the time was the same as when I turned my laptop off yesterday.
> 
> Here is the line in my /etc/rc.conf file now:
> ...

 

Hmm, sorry I wasn't more helpful.  If I understand correcly, it's off the same amount each time you reboot ... how far is it off exactly?

----------

## xavier10

 *lookinin wrote:*   

> 
> 
> Hmm, sorry I wasn't more helpful.  If I understand correcly, it's off the same amount each time you reboot ... how far is it off exactly?

 

It is off by the time it has been turned off.

If I turn it off at 10PM and then start it again at 8AM on the next day, it still believes that it is 10PM, the last day. It just looks like the system is able to track clock moves when it is running, writes down the time somewhere and reads it there instead of the hardware clock when I start it again.

If anyone has an idea, I would be happy to hear about it (and please do not tell me never to turn it off  :Very Happy: ). It used to work perfectly and this is not a hardware problem, since OSX still belives in the right time.

Xavier

----------

## lookinin

 *xavier10 wrote:*   

> 
> 
> It is off by the time it has been turned off.
> 
> Xavier

 

Sorry xavier10, that's not what I meant - How much does the time deviate from what it should be?

----------

## fraenhawk

He means exactly that. If he turns the computer off for 8 hours, the clock is off by 8 hours. If he turns the computer off for only 2 hours, it's only off by 2 hours.

It's not that the clock is drifting gradually. It's more like time freezes and the clock doesn't update while the PC is off. If he turns it off at 10 PM, when he turns it back on (no matter how much later), it starts the clock running again from 10PM.

Normally I would suspect that the BIOS battery has no charge, thus it's losing time, except two things. It's not resetting to midnight 1/1/2000, and most importantly he says that if he boots into MacOSX (I guess he's dual booting the PC) the clock does not behave strangely so it can't be the battery.

----------

## lookinin

 *fraenhawk wrote:*   

> He means exactly that. If he turns the computer off for 8 hours, the clock is off by 8 hours. If he turns the computer off for only 2 hours, it's only off by 2 hours.

 

I see it now - thanks - I was in a hurry and misunderstood.  In that case, I'm really not sure what's going on if it's working correctly in OSX.  NTP might be the way to go if no other solution presents itself.

----------

## skate

Back to something you said earlier...

Depending on your syslogging, emerge may have been logged in your syslog. i know mine does, although i have quite a tweaked system now...

might be a pain to go through to try find what you emerged, but it may also help to track down your problem...

if it is a problem with a latest emerge, try emerge sync, and then emerge --update world to bring your system a bit newer... might have been a bug that was quickly fixed...

an extra question...

when you switch your computer off from linux, then load into OSX, does OSX pickup the time that linux left off?

if you switch the machine off in OSX, does linux then pickup the last time that linux was switched off?

hope you understand what i mean...

----------

## xavier10

 *fraenhawk wrote:*   

> He means exactly that. If he turns the computer off for 8 hours, the clock is off by 8 hours. If he turns the computer off for only 2 hours, it's only off by 2 hours.
> 
> 

 

Yes, you have read me right here.

Of course, when the computer is running there is no delay. The problem occurs when I turn it off for some time; then, I have to think about setting the right time again.

This is rather annoying. If I forget this, I get strange problems, for instance with the cvs repositories I use or with make, which are due to the time error.

I guess the kernel reads the time somewhere and should set the system clock at start up. Did someone investigate this ? I am not precisely free to do it right now.

Xavier

----------

## gentsquash

xavier10, when you run

[edit]Corrected --testing to --test in the following cmd.[/edit]

```
hwclock --debug --test
```

does it produce output like this

```
hwclock from util-linux-2.12i

Using /dev/rtc interface to clock.

Last drift adjustment done at 1106803171 seconds after 1969

Last calibration done at 1106803171 seconds after 1969

Hardware clock is on UTC time

Assuming hardware clock is kept in UTC time.

Waiting for clock tick...

/dev/rtc does not have interrupt functions. 

  Waiting in loop for time from /dev/rtc to change

...got clock tick

Time read from Hardware Clock: 2005/01/27 07:31:59
```

except that there is an error message concerning the /dev/rtc device?

----------

## xavier10

This morning, things turned out even a little more funny.

I started linux and got wrong time. I did not change it.

I re-started under OSX and also got wrong time (the same as under linux roughly); I concluded I was hallucinating when I noticed the time was still ok under OSX a few days ago and the time battery could be dead. So I changed the date and went back to linux.

Then, guess what ? I did the same wrong time as at the last boot. Just as if my change under OSX had had no effect. I am sure the date was saved under OSX and displayed correctly.

I am puzzled. Could it be that changing the /etc/rc.conf file caused linux to overwrite the clock read by OSX ? But this could not make sense; it should read the hardware clock.

In case, the problem is the battery, then linux has been able to take the last set clock up to now. I just could see that it did not read a time set under OSX, so I am right postulating there should be also a problem here, no ?

Or I am just having several problems at a same time...

 *gentsquash wrote:*   

> xavier10, when you run
> 
> ```
> hwclock --debug --testing
> ```
> ...

 

The "--testing" option is not recognized.  Here is the result of hwclock --debug:

```

hwclock from util-linux-2.12i

Using /dev/rtc interface to clock.

Last drift adjustment done at 1106770751 seconds after 1969

Last calibration done at 1106770753 seconds after 1969

Hardware clock is on local time

Assuming hardware clock is kept in local time.

Waiting for clock tick...

/dev/rtc does not have interrupt functions. Waiting in loop for time from /dev/rtc to change

...got clock tick

Time read from Hardware Clock: 2005/01/26 21:49:30

Hw clock time : 2005/01/26 21:49:30 = 1106772570 seconds since 1969

Wed Jan 26 21:49:30 2005  -0.797339 seconds

```

And I am also given a wrong hardware clock time here.

I do not understand anything anymore.

Anyway, no error about /dev/rtc...

xavier

----------

## gentsquash

xavier10, my fingers made a present participle of the option; it

should be --test.  It is not necessary; I wanted to protect you

in case you ran the command as root.  (`hwclock --debug' works

for a normal mortal.)

I think that this will test your battery:  Does the repeated cmd

show different times, e.g

```
%  hwclock && hwclock

Thu Jan 27 04:11:56 2005  -0.020717 seconds

Thu Jan 27 04:11:57 2005  -0.988158 seconds
```

----------

## xavier10

 *gentsquash wrote:*   

> 
> 
> I think that this will test your battery:  Does the repeated cmd
> 
> show different times, e.g
> ...

 

```

$ hwclock --test && hwclock --test

Wed Jan 26 23:03:06 2005  -0.821010 seconds

Wed Jan 26 23:03:07 2005  -0.996674 seconds

```

As you can see, I get different times. However none of this is correct. I have the system clock set to:

```

$ date

Thu Jan 27 10:37:30 CET 2005

```

Should I conclude my battery is still alive ?

If yes (I hope so), what else should I consider to be wrong ?

Xavier

----------

## fatalglitch

well, while you are diagnosing, a quick (read: NOT PERMANENT) fix would be to install and enable ntp to set your system clock on boot.

Also, if your /etc/localtime is symlinked to a timezone, in /etc/rc.conf your setting should be "local" not "UTC"

I'd take a multimeter to your bios battery, just to be able to rule that out.

-Tom

----------

## gnomeza

Delete /etc/adjtime in Gentoo and see if that has any effect.

When dual-booting between OSX and Gentoo your bios clock should always be set in UTC mode.

See my forum post https://forums.gentoo.org/viewtopic.php?p=1799636&highlight=#1799636

for more info on syncing OSX and Gentoo clocks.

Your problem does sound strange though.

It's like Linux isn't setting its system clock to the bios clock on boot up.

----------

## xavier10

 *gnomeza wrote:*   

> Delete /etc/adjtime in Gentoo and see if that has any effect.
> 
> When dual-booting between OSX and Gentoo your bios clock should always be set in UTC mode.
> 
> See my forum post https://forums.gentoo.org/viewtopic.php?p=1799636&highlight=#1799636
> ...

 

Thank you very much for your reply. I will definetely give it a try today.

What about the /etc/rc.conf file ? Do you also set it to local to have correct time under linux ? 

fatalglitch: thanks for your post. The /etc/localtime is symlinked to a timezone; the /etc/rc.conf is set to local. I would be happy to look at the battery, but this may require taking apart a 2000$+ laptop which belongs to my lab... Will see if it is feasible after I try out gnomeza's solution.

Xavier

----------

## xavier10

Ok, the idea of gnomeza worked. I wiped out /etc/adjtime and reset the system clock and everything is fine now  :Smile: 

Thanks to all of you who answered in this thread.

Xavier

----------

## GaryMercer

Thanks for this post and all replies.  I was having the same problems and removing the /etc/adjtime worked for me.

----------

## xavier10

I have just seen that my old laptop is going to take the same route...  :Very Happy: 

So this is a frequent issue; maybe it should be put in some FAQ... Or is it already there ?

Xavier

----------

## gentsquash

Well done gnomeza.

I was next going to suggest, not deleting "/etc/adjtime", but

examining its three lines to see if they have the correct format.

May I ask that anyone who is having this problem post a copy of

his "/etc/adjtime" before deleting it?  (and its file-permissions)

xavier10 or GaryMercer, would you check to see if "/etc/adjtime"

has been re-created on your system?

----------

## xavier10

 *gentsquash wrote:*   

> Well done gnomeza.
> 
> I was next going to suggest, not deleting "/etc/adjtime", but
> 
> examining its three lines to see if they have the correct format.
> ...

 

I actually put zeroes into /etc/adjtime instead of deleting it.

Here is the one of my old lap:

```

-0.002107 1104924856 0.000000

1104924856

UTC

```

Does not seem too bad though...

Xavier

----------

## gentsquash

Now that you have logged-in-out several times, has your zeroed-out

"/etc/adjtime" been rewritten?  Would you post its current contents?

As for your laptop machine, perhaps you could store a copy at

"/etc/adjtime.27Jan2005", then (having set the system clock to the

correct time with `date') try command

```
hwclock --systohc --test
```

and, if you feel comfortable with it, re-executing without the

"--test".   Does the laptop's hardware clock still malfunction?

----------

## xavier10

 *gentsquash wrote:*   

> Now that you have logged-in-out several times, has your zeroed-out
> 
> "/etc/adjtime" been rewritten?  Would you post its current contents?
> 
> ```
> ...

 

The hardware clock seems to work well. I observe no delay. I will not go further  :Smile: 

Here is the new /etc/adjtime:

```

0.000000 1106881062 0.000000

1106881062

LOCAL

```

Xavier

----------

## uruguru

Hi.

I changed my localtime from WET (entered by accident) to CET.

After that I got the above mentioned problems with time totally missadjusted after reboots.

Here's my adjtime before deletion.

```
-163768.741794 1109939308 0.000000

1110322345

UTC

```

Here's my new adjtime.

```
0.000000 1110755476 0.000000

1110755476

UTC

```

Here's my date before deletion of adjtime

```
Fri Mar  4 13:31:51 CET 2005
```

And the right one.

```
Mon Mar 14 22:19:18 CET 2005
```

Is this considered to be a bug?

Should it be reported?

By the way.I also had to change CLOCK from UTC to local to get the right time when booting win98 (thats a game-platform that my kids use).

----------

## Castoro

Hi all.

I've got the same problem... seems that deleting /etc/adjtime can solve, but every time i reboot, it is newly created.

Is there a way to prevent this issue? Filling with "0", can avoid the time-shift ?

Thanks.

----------

## Castoro

I'm the only one who find adjtime everytime i reboot ?

----------

## nelix

Same issue on my ibook.

----------

