LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   NTP issues and system time drift (https://www.linuxquestions.org/questions/linux-newbie-8/ntp-issues-and-system-time-drift-916829/)

Cyked 12-02-2011 04:47 PM

NTP issues and system time drift
 
Rather than repost everything:
http://ubuntuforums.org/showthread.php?t=1793516

I updated the thread there today.

It seems as though, from what I have read, that there may be another app/tool that is tinking with the time other than NTPD?

from yesterday checking HWclock against system time after doing a ntpdate sync and starting NTPD again it would slowly creep ahead, but never more than 5 seconds
Code:

Thu 01 Dec 2011 01:22:22 PM PST -0.665057 seconds
Thu Dec 1 13:22:23 PST 2011

and then it would appear to sync and bring in back inline.
Code:

Thu 01 Dec 2011 01:28:26 PM PST -0.529493 seconds
Thu Dec 1 13:28:26 PST 2011

Then this morning I checked HWclock against system time and it ~5 min off. Now in the afternoon its 8 minutes off:
Code:

Fri 02 Dec 2011 08:49:05 AM PST -0.417030 seconds
Fri Dec 2 08:52:24 PST 2011


Any help is appreciated.

tronayne 12-03-2011 03:22 PM

You might want to check the battery if it's an older box (the hardware clock runs from the battery and if the battery is low, dead or whatever...). This will be a problem if the system is turned off between sessions.

Another thing you might want to look into is the hwclock utility, the section on --adjust and the section The Adjust Function about line 280-ish in the manual page. You can "walk" the adjustment (carefully! a little at a time) to bring the hardware clock in sync with the system clock.

Additionally, look at the drift file in /etc/ntp. There should be a floating-point number there; if /etc/ntp/drift does not exist, do something like this
Code:

echo 0.0 > /etc/ntp/drift
Might help.

Of course, if your NTP stuff isn't in /etc/ntp, adjust the above to where it actually lives.

Hope this helps some.

michaelk 12-04-2011 11:23 AM

From your other post it appears that you are polling the desired timer server. I never saw it synched i.e. the * before the server name in the output of the ntpq -p command. If you zero out the drift file it will take 900s or so for ntp to perform its inital calibration.

The hardware clock is not very accurate and I believe that if the system clock is synched via ntp it will be updated every 11 minutes.

Cyked 12-04-2011 02:27 PM

Doesn't the hwckock cmd tell me the hardware time? That is actually acurate.

tronayne 12-04-2011 04:14 PM

Quote:

Originally Posted by Cyked (Post 4541886)
Doesn't the hwckock cmd tell me the hardware time? That is actually acurate.

Yes, it does -- which indicates that the system clock isn't getting synchronized by NTP.

When you're in sync, running ntpq -p will show something like this:
Code:

/usr/sbin/ntpq -p
    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 LOCAL(0)        .LOCL.          10 l  12h  64    0    0.000    0.000  0.000
+247.conarusp.ne 216.218.254.202  2 u  870 1024  377  1324.69  -4.405  68.871
*ntp.cox.net    .GPS.            1 u  756 1024  377  1493.03  15.182  16.085
+rapture.knovide 64.90.182.55    2 u  317 1024  377  1703.45  -73.680  53.170

The asterisk indicates that the clock is synchronized to ntp.cox.net.

So, take a look at your /etc/ntp.conf and perhaps try this:
Code:

server  127.127.1.0    # local clock
fudge  127.127.1.0 stratum 10
#server  pool.ntp.org
server  0.us.pool.ntp.org
server  1.us.pool.ntp.org
server  2.us.pool.ntp.org

The local clock set to stratum 10 is a fall-back for when the network goes away (NTP will initially synchronize LOCAL, then to an external server, and more or less syncs to itself for a while when the network goes away).

The three pool servers allow NTP to synchronize to the best electrically close external server; I use three US pool servers -- if you're not in the US, you can choose from pool servers in your area or simply
Code:

server  127.127.1.0    # local clock
fudge  127.127.1.0 stratum 10
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org

Bottom line: if you run ntpq -p and do not see the display similar to the above, your system clock is not synchronized and it will wander all over the place.

Hope this helps some.

timetraveler 12-04-2011 04:50 PM

Ditch NTP altogether and use clockspeed?

michaelk 12-04-2011 05:38 PM

The only purpose of the hardware clock is to provide a time source for the system clock when the computer is powered on. The hardware clock and system clock are independent of each other. The hardware drift correction is stored in /etc/adjtime and the system clock correction is stored in the ntp driftfile.

http://www.ntp.org/ntpfaq/NTP-s-sw-clocks-quality.htm

Have you made any recent changes to your system?

Cyked 12-04-2011 07:19 PM

To be clear. I don't expect my system to sync to the hw clock. If I reboot system syncs to the hw clock correctly. I hardly reboot so drift happens when on. I reboot maybe once q month. If that.
[Quite]
Have you made any recent changes to your system?[/QUOTE]

This has been going on for months


Ill try some of things suggested above next time I remote in. Thanks for the tips so far. Ill repoet back.

Cyked 12-05-2011 11:23 AM

Code:

ntpq -p
    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 time-a.nist.gov .ACTS.          1 u    -  64    1  123.235  -171828  18.926
 mail.freerip.co 67.18.187.111    3 u    3  64    1  34.384  -171826  0.001
 ponderosa.piney 64.90.182.55    2 u    2  64    1  102.507  -171827  0.001
 ntp1.Rescomp.Be 169.229.128.214  3 u    2  64    1  15.667  -171827  0.001
 clock.trit.net  192.12.19.20    2 u    1  64    1  36.483  -171827  0.001

I added the "fudge 127.127.1.0 stratum 10" to my ntp.conf file.

What SHOULD the drift file have? x.xxx, but previously my drift file was something like -10.197. Should it be a negative number?


After making the changes (i reverted the drive file to -10.197 it was a few days ago, and adding back the ntp pool servers to the conf file), stopping and starting NTP...

My system time is synced and OK. BOTH these times are very very very close to my Win7 machine. I'll see what happens the remainder of the day and check, and check times again in the AM.

Code:

sudo hwclock;date
Mon 05 Dec 2011 09:22:12 AM PST  -0.076789 seconds
Mon Dec  5 09:22:12 PST 2011


michaelk 12-05-2011 12:30 PM

Wait until the value of reach becomes 377 and post the output of ntpq -p again. Hopefully your system will show that it is synced to a time server.
Yes, it can be a negative number. Depends if your system clock runs fast or slow.

Cyked 12-05-2011 12:34 PM

Code:

hwclock;date
Mon 05 Dec 2011 10:34:14 AM PST  -0.268159 seconds
Mon Dec  5 10:34:14 PST 2011
dpaul01@tux:~$ ntpq -p
    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 time-a.nist.gov .ACTS.          1 u  63  64  377  100.387  -7508.1 1476.41
 ibird.bahosting 208.53.158.34    3 u  15  64  377  97.558  -7754.1 1485.46
 173.244.211.10. 131.107.13.100  2 u  20  64  377  36.406  -7728.8 1478.34
 cheezum.mattnor 129.7.1.66      2 u    4  64  377  52.893  -7817.9 1498.77
 name1.glorb.com 130.207.244.240  2 u  38  64  377  81.931  -7645.4 1494.30


michaelk 12-05-2011 01:10 PM

The output does not show your computer locked to a time server i.e. (*).
You restarted ntp but output does not show your local (fudge) clock.
Your offset has decreased from ~171 seconds to ~7 so something is happening...

Just to verify this is not a virtual machine?

Cyked 12-05-2011 01:12 PM

Correct, its not a VM.

Cyked 12-05-2011 01:30 PM

So why is it not locking to a server?

michaelk 12-05-2011 03:09 PM

What type of computer desktop or laptop?
Can its clock speed vary? If so try disabling it.
And you could try disabling apic.

http://www.math.ucla.edu/~jimc/docum...wont-sync.html


All times are GMT -5. The time now is 05:26 AM.