Clock gets set wrong every time I boot into another OS

Red Squirrel

No Lifer
May 24, 2003
67,395
12,141
126
www.anyf.ca
Every time I boot into Windows, the time will be wrong, then when I boot back in Linux it will be WAY wrong. Like several hours. i googled this and it seems to be a common bug with the way Linux handles time. It's telling me to edit /etc/conf.d/clock but I don't have /etc/conf.d. What do I do? I'm using Xubuntu.

Also is this a bug in Linux, or in Windows? Is there something in Windows I can do to fix it?
 

weovpac

Golden Member
Apr 12, 2000
1,381
0
76
The easy fix for this is to use NTP[1,2]. Install the ntp package on the Linux side and that will correct the time for you. Read [3] for basic set up and info.

The default /etc/ntp.conf should work just fine, but if you want comment out the default servers and use ones closer to your region. Like:

Code:
server 0.us.pool.ntp.org iburst
server 1.us.pool.ntp.org iburst
server 2.us.pool.ntp.org iburst
server 3.us.pool.ntp.org iburst

[1] http://www.ntp.org/
[2] http://www.pool.ntp.org/en/
[3] http://www.computerbob.com/guides/guide_using_ntp_on_a_debian_pc.php

There is probably something similar for windows, so you don't have to manually need to update the clock every time you boot into it.

No dual booting here, so no idea on the cause.
 
Last edited:

theevilsharpie

Platinum Member
Nov 2, 2009
2,322
14
81

weovpac

Golden Member
Apr 12, 2000
1,381
0
76
It's not a bug, but a difference in how Windows and Linux store time in the BIOS.

Linux (and every other operating system on the planet not named Windows) stores BIOS time in UTC, and uses time zone offsets to convert to your local time. Windows stores BIOS time in your local time directly.

To resolve this, see here: https://help.ubuntu.com/community/UbuntuTime#Multiple_Boot_Systems_Time_Conflicts

Thanks for the info, good to know these things. Would still use NTP tho.
 

Red Squirrel

No Lifer
May 24, 2003
67,395
12,141
126
www.anyf.ca
I have NTP, so the problem does eventually fix itself. So it's basically Windows doing it wrong then? I'll try that reg patch in the link to see if it fixes it.
 

mv2devnull

Golden Member
Apr 13, 2010
1,498
144
106
I doubt the Windows registry change helps; at least it did not reliably stay in UTC.

Motherboard has a hardware clock -- hwclock. When OS starts, it gets time from the hwclock. Then it keeps time in software. When OS shuts down, it writes the software time back to hwclock. It is assumed that the hwclock is not as reliable than software. NTP adjusts the software clock during runtime in order to keep it "in time" with "reliable timesource". That is good.

Make the Xubuntu to assume that hwclock has local time. It will work fine with that assumption and it will update the hwclock to what Windows expects, when you reboot.
 

VinDSL

Diamond Member
Apr 11, 2006
4,869
1
81
www.lenon.com
I had this same problem with Lubuntu, but only on Dell computers.

I "fixed" the problem by setting the NTP timezone to Africa/Algeria. LoL! :D
 

mv2devnull

Golden Member
Apr 13, 2010
1,498
144
106
You have to set the timezone info too, but using bogus timezone to compensate for erroneous clock is not the correct method.


Off Topic anecdote: Once upon a time there was a program called "MS Word". This program did offer "shortcut keys". For example, "Ctrl+Alt+2" applied a paragraph style. On some locales, the keyboard layout contains "AltGr" modifier instead of "Right Alt". "Alt Gr" generates essentially "Ctrl+Alt". "AltGr+2" were supposed to create the @-sign, useful for typing an email address. Obviously, the Word shortcut overruled that.

What was the frequently proposed solution? Define in Word a "user defined shortcut" -- "Ctrl+Alt+2" to run command "Insert symbol '@'". That did override Word's default shorcut, which in turn did override the default of the keyboard: "@". That did appear to restore original function, but was slow. The better method (no, I don't say "banish Word") was to simply remove the default shortcut.

Moral of the story: keep hwclock in local time and set timezone correctly. Then pray that Daylight Saving Time shenanigan does't ruin your day.
 

MrColin

Platinum Member
May 21, 2003
2,403
3
81
Every time I boot into Windows, the time will be wrong, then when I boot back in Linux it will be WAY wrong. Like several hours. i googled this and it seems to be a common bug with the way Linux handles time. It's telling me to edit /etc/conf.d/clock but I don't have /etc/conf.d. What do I do? I'm using Xubuntu.

Also is this a bug in Linux, or in Windows? Is there something in Windows I can do to fix it?

I have had the same problem and came up with this script to run at windows startup.
Code:
net start w32time 
ping 192.168.1.1 -n 1 -w 6000 >NUL
w32tm /resync
 

Red Squirrel

No Lifer
May 24, 2003
67,395
12,141
126
www.anyf.ca
Seems to have worked to tell Linux to keep local time. Now hopefully daylight saving time does not mess that up. Are we offset now, or is that in winter? I always forget.