Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My clock starts running out of sync in Ubuntu which doesn't happen in Windows. The problem is that it just starts losing time after a moment of syncing it with an NTP server, that means the clock is broken.

So How can I make the system use the hardware clock instead(I tried adjtimex).

BTW: please don't suggest the CMOS battery, it's not the correct answer.

share|improve this question
1  
To clarify... you think that your internal clock is /more/ accurate than using NTP? Or are you suggesting that NTP is broken on your system? Windows uses time.windows.com or something similar to sync its clock, whereas Ubuntu doens't ship with NTP enabled, so it's more likely that you actually /want/ to enable NTP on Ubuntu? Maybe? –  Scaine Mar 19 '11 at 19:57
1  
No. NTP is fine, but the clock is broken in Ubuntu. When you choose to disable time sync in windows, it just keeps working, but when you either install NTP or or manually enter the time, the clock starts to get delays. For instance, the time here is 08:38 AM, in Ubuntu, however, it is 07:59 AM. If I log in NOW to Windows, I will get something very close to 08:38 which means that windows is taking time from a source(Time servers disabled) that Ubuntu fails to use. –  Reda Lazri Mar 20 '11 at 7:39
    
Just a stab, do you have the correct timezone set? –  theTuxRacer Apr 19 '11 at 7:29
    
What happened when you tried adjtimex? I use it and it works very well on most machines, though on some the rate offset changes suddenly every once in a while. Though in my experience, the adjtimexconfig program usually gets the initial adjustment wrong. I just use ntpdate to manually tweak the FREQ and TICK values in /etc/default/adjtimex I can get it to stay within a few seconds for weeks, without ntp or ntpdate. –  nealmcb Apr 29 '11 at 19:32
    
@nealmcb: I wasn't sure adjtimex would help me, that's why I didn't test it a lot, I did one thing with it, I updated using ntpdate and then sent that time to the bios' clock, it worked but it couldn't keep it for a long time. –  Reda Lazri Apr 30 '11 at 15:06

3 Answers 3

up vote 3 down vote accepted

By default, Ubuntu only sets the time when a network interface comes up. It does this with a small piece of the "ntp" system: ntpdate. If your machine stays connected and keeps running for days or weeks, even the best internal clock will eventually go out of sync.
Ubuntu also doesn't try to adjust your internal clock by default, and it sounds like your clock is badly adjusted. The real time clock (hardware clock) in most systems is also not very good over the long term.

So if you want better time, I can recommend two options:

  • Install the full "ntp" package to get the Network Time Protocol, which regularly looks at Internet time servers and keeps your clock within milliseconds of the right time. See some good instructions here: Install NTP.... You can also install it from the Ubuntu Software Center. This is easy and typically pretty foolproof, if your machine is usually on the Internet and doesn't have really nasty firewalls cutting off ntp.

  • Manually adjust the frequency of your internal clock, using the adjtimex package. Actually, when you install adjtimex, it runs adjtimexconfig which sets values in /etc/default/adjtimex. But it does so quickly using the hardware clock, and in my experience the results are usually somewhere between bad and terrible. Some machines are hard to tune well, but I've had good luck with most of my machines by doing the manual calculation necessary to figure out the right FREQ and TICK values to put in /etc/default/adjtimex. To go this route, start by installing adjtimex via Applications/Ubuntu Software Center. To figure out manual settings for FREQ and TICK, see the nice calculator at Tuning with adjtimex as an alternative to running ntpd. That page also notes that your choice of "clocksource" can affect how accurate your clock is. The hpet (High Precision Event Timer) seems more accurate than the tsc (Time Stamp Counter).

There are tips for dealing with other glitches at UbuntuTime - Help.ubuntu.com

share|improve this answer
1  
Thanks, I already fixed this by upgrading to Natty, however, this is the most informative answer. :) –  Reda Lazri May 1 '11 at 9:31
    
Thanks :) But I wonder why upgrading to natty would have helped? –  nealmcb May 1 '11 at 12:53
    
It did help, I don't know how but it helped. –  Reda Lazri May 4 '11 at 14:39
1  
Thank you; adjtimex seems to be working beautifully. I'm down to a few seconds per day, and am getting closer to ideal. –  eswald May 18 '11 at 20:40

I'm not sure things work the way you're describing. I.e., there are no "software" clock process/application which either uses BIOS clock or an ntp server and which can be "broken" in Ubuntu but working in Windows. In any case the info you see on the screen comes from BIOS clock.

If NTP server is enabled, the data coming from it is used to adjust the BIOS/hardware clock, and, when the hardware clock is thought to be "incorrect", NTP daemon adjusts time gradually in small increments instead of setting it straight away. This is done to avoid sudden "jumps" in system time which may cause all sorts of trouble (i.e. an event which happens after some other event but at earlier time).

Which perfectly explains the behaviour you're seeing - as soon as the "correct" data comes from the NTP server, the daemon starts gradually adjusting your system time.

I think your timezone/daylight saving time may be set incorrectly. Another possibility may be that Ubuntu expects the BIOS clock to be set to UTC time while Windows sets the clock in your local timezone, which results in Ubuntu thinking your system clock are late/early by your GMT offset

This document may be helpful: https://help.ubuntu.com/community/UbuntuTime#Multiple%20Boot%20Systems%20Time%20Conflicts

share|improve this answer

Go to system/preferences/time and date, then unlock the settings by clicking on the little padlock.

Time and Date settings

Change your configuration to "manual" (that's the default, unless you've installed NTP) and then manually update your system time to whatever you need.

share|improve this answer
    
I know this solution, I doesn't work. –  Reda Lazri Mar 20 '11 at 7:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.