# System clock always wrong

## kahlil88

My system clock is always off by a few hours. I managed to set it with ntpdate once, but after rebooting it's wrong again. My CMOS battery works fine and the time is correct in Windows.

----------

## smerf

It is precisely N hours where N is integer? Do you have right time zone selected?

What do you get after egrep ^TIMEZONE=\|^CLOCK= /etc/conf.d/clock?

----------

## Leon_UK

If I recall correctly I don't remember if it was in the handbook or a comment in the "/etc/conf.d/clock" it used to say if you dual boot with windows you should set that file to local or you will keep getting an incorrect time.

```
nano -w /etc/conf.d/clock
```

if you do not have that file it should be

```
nano -w /etc/conf.d/hwclock
```

mine looks like this 

```
$ cat /etc/conf.d/hwclock 

CLOCK="UTC"

TIMEZONE="Europe/London"
```

Though if you dual boot with windows UTC should be changed to local

```
$ cat /etc/conf.d/hwclock 

CLOCK="local"

TIMEZONE="Europe/London"
```

The timezone setting is one other possibility as to what could be causing an incorrect clock, your original setting could have been overwritten in an update or something, to be sure it is not the cause, you could copy that over again.

find your timezone if you do not know it with

```
 ls /usr/share/zoneinfo

```

then (using my timezone as the example)

```
cp /usr/share/zoneinfo/Europe/London /etc/localtime
```

and make sure that is set in /etc/conf.d/clock (or "hwclock" depending on which you have) as mine is above with TIMEZONE=

hopefully this would solve your problem.

----------

## kahlil88

It worked! Thanks for your help.  :Very Happy: 

----------

## jsowoc

I was getting this exact problem despite following the instructions in the handbook:

http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=8#doc_chap3

I didn't know I'm supposed to edit hwclock...

Who should we contact to update the handbook to say: "either use /etc/conf.d/clock or /etc/conf.d/hwclock" ?

----------

## NeddySeagoon

jsowoc,

The handbook is written around baselayout1 as that is what stable gentoo provides.

With baselayout2, the setup changes and there is a migration guide to ensure an smooth transition.

----------

## muhsinzubeir

clock in my box was also not working...didnt know why though, as the /etc/conf.d/clock was correct.I removed it and use /etc/conf.d/hwclock and clock working correct.

But I still have that  warning Factory settings of the clock as no /etc/conf.d/clock in there...if use this file I get 2hrs ahead of my time regardless of the settings in there.

Where can I tell the system to check /etc/conf.d/hwclock instead?

P:S

baselayout-->sys-apps/baselayout: 1.12.11.1

----------

## NeddySeagoon

muhsinzubeir,

There are two scenarios.

1. You dual boot with windows.

In your BIOS, set the time by your wristwatch.

copy /usr/share/zoneinfo/localtime to /etc/localtime

In your /etc/conf.d/clock set your timezone to localtime

You must boot into Windows to get changes in daylight saving time to take effect because windows changes your BIOS time.

2. You use Linux Only

In your BIOS, set the time to UTC

copy /usr/share/zoneinfo/<city_near_you> to /etc/localtime

In your /etc/conf.d/clock set your timezone to <city_near_you>

Daylight savings time changes happen in real time.

----------

## justinkb

thanks for clearing that up neddy, i ended up changing the clock for DST in the bios, which gives the same effect as you say.

----------

## muhsinzubeir

Thanks Neddy....got it now...issue was in the Bios, i noticed that 3 of my boxes were set utc+2....but I couldnt fix one of them, I cant access the Bios...so I settup ntp-client en I think I can live for a while...

Cheers

----------

## alatar

 *NeddySeagoon wrote:*   

> muhsinzubeir,
> 
> There are two scenarios.
> 
> 1. You dual boot with windows.
> ...

 

What will happen if I set the time to UTC in the first scenario? I am asking because a had done that and my Gentoo works fine. But maybe I am missing something?

----------

## justinkb

your time will be fudged up in windows if you do that.

----------

