LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Debian Lenny Severe time drift (https://www.linuxquestions.org/questions/linux-software-2/debian-lenny-severe-time-drift-783370/)

knappster 01-19-2010 11:20 PM

Debian Lenny Severe time drift
 
I was running Debian Etch for a while and upgraded to Debian Lenny months ago. After the upgrade I began to notice that I was losing time pretty severely on the desktop clock (On the order of more than 1 second every minute!). After trying to troubleshoot it for a couple days I finally gave up and took the easy way out and added a crontab entry:
Code:

*/5 * * * * /usr/sbin/synctime.sh > /tmp/synctime.log 2>&1
where synctime.sh
Code:

#!/bin/bash
/etc/init.d/ntp stop
/usr/sbin/ntpdate ntp-0.cso.uiuc.edu
/etc/init.d/ntp start

Which took care of the time drift because it updated the time every 5 minutes. I recently noticed an online game lagging exactly every 5 minutes and finally pinpointed it to this timekeeping script I wrote. I would like to fix the time drift issue on this PC properly now but have not found any helpful documentation online yet. If it helps, my motherboard is:

Foxconn A74MX-K

And I have not restarted the computer yet, but if I remember correctly from before, the clock is accurate on startup but then starts to drift immediately. So the amount of drift depends on how long the computer is on.

Any ideas on what could point me in the right direction? Thanks.

jimbo1954 01-20-2010 03:04 AM

Looks like you are not running ntp, Network Time Protocol. In Debian, go into Synaptic, and search for NTP. Install that, and it will go out to time servers on the net and get and maintain the correct time on the system. If you have an intermittent connection, rather than an always-on one, you may also like to use ntpdate.

minrich 01-20-2010 03:16 AM

I have/had the same problem on my Ferrari laptop, I have gotten it down to under a minute a day using adjtimex which is in stable package repo. I gave up on ntp since I am not permanently connected to the interwebbienet thingamajig. My Bios/cmos hwclock has been stable so every now and then I run adjtimexconfig which takes 70 seconds or so and it is gradually getting my system clock to run more accurately.

knappster 01-20-2010 07:22 AM

Quote:

Originally Posted by jimbo1954 (Post 3833181)
Looks like you are not running ntp, Network Time Protocol. In Debian, go into Synaptic, and search for NTP. Install that, and it will go out to time servers on the net and get and maintain the correct time on the system. If you have an intermittent connection, rather than an always-on one, you may also like to use ntpdate.

I do have ntp installed which is why my script stops it in order to call ntpdate... so what you are saying is the same as what I was already using.

I have tried adding "iburst" to the end of the server argument in the ntp.conf file and have not yet seen any improvement. I'll have to check into the adjtimex that you recommend minrich. It's just that I do have an always on internet connection so I don't understand why this is happening in the first place...

jimbo1954 01-20-2010 08:08 AM

I take your point, you are issuing commands to ntp, so you possibly have ntp on board, but it doesn't appear to be working (sorry to state the obvious!). Things to check:
1) Is ntp able to freely transit any firewalls;
2) Is ntp correctly configured (what time server, if any, is it using)
3) Is it *really* running? yes, I know you are issuing start commands, but is it genuinely starting and running properly? Issue command:

ps -ef | grep ntp

and you should get something like:

jim@bastion:~$ ps -ef | grep ntp
ntp 5248 1 0 Jan19 ? 00:00:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -u 108:112 -g
jim 22464 22444 0 13:59 pts/1 00:00:00 grep ntp
jim@bastion:~$

Also look in ntplogs and syslog to see if anything is showing up there...

knappster 01-20-2010 07:23 PM

Quote:

Originally Posted by jimbo1954 (Post 3833457)
I take your point, you are issuing commands to ntp, so you possibly have ntp on board, but it doesn't appear to be working (sorry to state the obvious!). Things to check:
1) Is ntp able to freely transit any firewalls;
2) Is ntp correctly configured (what time server, if any, is it using)
3) Is it *really* running? yes, I know you are issuing start commands, but is it genuinely starting and running properly? Issue command:

ps -ef | grep ntp

and you should get something like:

jim@bastion:~$ ps -ef | grep ntp
ntp 5248 1 0 Jan19 ? 00:00:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -u 108:112 -g
jim 22464 22444 0 13:59 pts/1 00:00:00 grep ntp
jim@bastion:~$

Also look in ntplogs and syslog to see if anything is showing up there...

#ps -ef | grep ntp
ntp 7648 1 0 07:02 ? 00:00:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -u 108:112 -g[/code]

The computer has been running for between 12 and 13 hours and has lost over 17 minutes. There is nothing in the syslog file which only contains information for about the last 12 hours. I don't know if there are any other ntp logs. Any other suggestions?

JonathanWilson 01-20-2010 07:53 PM

Just wondering, have you tried turning on the pc, check the bios clock, boot as far as the boot loader but don't select an OS to load... leave it a while, re-boot pc and check bios clock.

Like wise check the bios clock, boot the os (leave it to drift) and then check the bios clock against the drift in the OS.

This will at least prove its the os causing the problem, and not the rtc/motherboard. Reason I ask is that I had a similar problem, turned out the battery was on its way out and for some strange reason it was affecting the rtc even when the board was attached to live power.

knappster 01-20-2010 10:09 PM

Quote:

Originally Posted by JonathanWilson (Post 3834291)
Just wondering, have you tried turning on the pc, check the bios clock, boot as far as the boot loader but don't select an OS to load... leave it a while, re-boot pc and check bios clock.

Like wise check the bios clock, boot the os (leave it to drift) and then check the bios clock against the drift in the OS.

This will at least prove its the os causing the problem, and not the rtc/motherboard. Reason I ask is that I had a similar problem, turned out the battery was on its way out and for some strange reason it was affecting the rtc even when the board was attached to live power.

No I have not. I can say that:
Code:

hwclock --show
is about 8.5 minutes ahead of the system clock, which is now about 21 minutes behind the actual time. If I have some spare time I will try your suggestion, but it just doesn't feel like that should be the issue since it has been a problem for months.

jimbo1954 01-21-2010 02:44 AM

Curious...OK, lets get down to the nitty-gritty :)

Can you post up your /etc/ntp.conf, so we can check that. Also, assuming that in that file, you are pointing at the timeservers:

server 1.debian.pool.ntp.org
server 2.debian.pool.ntp.org
server 3.debian.pool.ntp.org

can you attempt a ping to them (if you are pointing at others, then change your ping target accordingly). Post up the results of those pings as well.

It looks like ntp is up and running just fine, I'm beginning to think ts not able to communicate with its servers. A good suggestion about the BIOS clock, but the differences in BIOS and System clocks seem to point us away from that.

knappster 01-21-2010 05:54 AM

Code:

# /etc/ntp.conf, configuration for ntpd

tinker panic 0
driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable


# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to more than 300 low-stratum NTP servers.
# Your server will pick a different set every time it starts up.
#  *** Please consider joining the pool! ***
#  *** <http://www.pool.ntp.org/join.html> ***

# By default, exchange time with everybody, but don't allow configuration.
# See /usr/share/doc/ntp-doc/html/accopt.html for details.
restrict -4 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access,
# but only if cryptographically authenticated
#restrict 192.168.123.0  mask  255.255.255.0 notrust

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet,
# de-comment the next lines. Please do this only if you trust everybody
# on the network!
#disable auth
#broadcastclient
server ntp1.cs.wisc.edu iburst
server ntp-0.cso.uiuc.edu
server ntp0.cornell.edu
server tick.cs.unlv.edu

Code:

#ping -c 5 ntp1.cs.wisc.edu
PING caesar.cs.wisc.edu (128.105.39.11) 56(84) bytes of data.

--- caesar.cs.wisc.edu ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4012ms

Code:

#ping -c 5 ntp-0.cso.uiuc.edu
PING ntp-0.gw.uiuc.edu (130.126.24.53) 56(84) bytes of data.
64 bytes from ntp-0.gw.uiuc.edu (130.126.24.53): icmp_seq=1 ttl=47 time=26.5 ms
64 bytes from ntp-0.gw.uiuc.edu (130.126.24.53): icmp_seq=2 ttl=47 time=22.4 ms
64 bytes from ntp-0.gw.uiuc.edu (130.126.24.53): icmp_seq=3 ttl=47 time=23.6 ms
64 bytes from ntp-0.gw.uiuc.edu (130.126.24.53): icmp_seq=4 ttl=47 time=27.3 ms
64 bytes from ntp-0.gw.uiuc.edu (130.126.24.53): icmp_seq=5 ttl=47 time=23.7 ms

--- ntp-0.gw.uiuc.edu ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4018ms
rtt min/avg/max/mdev = 22.460/24.739/27.341/1.864 ms

Code:

#ping -c 5 ntp0.cornell.edu
PING dns3.cit.cornell.edu (132.236.56.250) 56(84) bytes of data.
64 bytes from dns3.cit.cornell.edu (132.236.56.250): icmp_seq=1 ttl=241 time=60.6 ms
64 bytes from dns3.cit.cornell.edu (132.236.56.250): icmp_seq=2 ttl=241 time=58.3 ms
64 bytes from dns3.cit.cornell.edu (132.236.56.250): icmp_seq=3 ttl=241 time=67.1 ms
64 bytes from dns3.cit.cornell.edu (132.236.56.250): icmp_seq=4 ttl=241 time=66.0 ms
64 bytes from dns3.cit.cornell.edu (132.236.56.250): icmp_seq=5 ttl=241 time=59.7 ms

--- dns3.cit.cornell.edu ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4017ms
rtt min/avg/max/mdev = 58.306/62.401/67.193/3.567 ms

Code:

#ping -c 5 tick.cs.unlv.edu
PING time-1.egr.unlv.edu (131.216.22.24) 56(84) bytes of data.

--- time-1.egr.unlv.edu ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4014ms

All of these ntp servers were in the Time and Date Settings that you can access through the Gnome clock. It must automatically update the ntp.conf file when you select them. I have tried it with them one at a time too.

I will switch it over to the debian timeservers to see if that helps. I am able to ping all 3 of them.

edit:

BTW the system time syncs fine when the system is booted or anytime I restarted ntp. After that it does not seem to attempt to resync.

jimbo1954 01-21-2010 09:14 AM

Hmmm, curious. Your .conf file looks almost identical to mine, except for the "tinker panic 0".

In order to keep ntpd running you have to tell it not to panic if it gets a very large time offset. The ntp daemon will accept an offset of up to 1000 seconds by default. Anything over that and it will panic and stop.This is fixed by following line:

tinker panic 0

which is more commonly found on VM Guest OSs, where there is no BIOS clock and the guest will start up without any knowledge of the real time.

The 0 says “accept any offset” which means that if your machine is suspended for a long time, if it starts and finds a gets a very large offset it will continue to try to sort the timing regardless.

You shouldn't need this line, but equally, it shouldn't be doing any harm (?)


Try the different servers, and also try commenting out the "tinker" line. I admit to being close to my limit of knowledge here, but if we can fix this, perhaps we'll both learn something :)

knappster 01-21-2010 12:12 PM

Unfortunately the tinker line was just added yesterday in hopes that it would help. I thought maybe that ntp was giving up by the time it checked the time because the offset was so great. Can you tell me what shows up in your syslog to see how often your ntp logs information? I thought it odd that it shows data when it first starts up, but nothing after that. Granted I shut down my computer every night so it never has an opportunity to run again if it only tries every 24 hoursish. I do have a DVR running Knoppmyth on Arch Linux that I could try to compare logs to as well, but if you have any information handy it would be appreciated. Thanks.

knappster 01-27-2010 01:43 PM

adjtimex was what I needed. I printed out the information and where ticks is supposed to be near 10,000, mine was at something like 9,637. I adjusted it up to 10,000 and it now is gaining about 2 seconds every 12 hours. That's not bad, but I will have to tinker some more with the ticks and frequency to get it slightly more precise. It is much better than losing minutes on the hour, though. Thanks for the tip!

minrich 01-27-2010 01:56 PM

You are welcome

jimbo1954 01-28-2010 04:25 AM

Now I'm puzzled! The system is on line (you say you run on-line games) but ntp doesn't keep it on time. It's great that adjtimex gets somewhere with the problem, but is that not simply covering up the real problem, which is that ntpd is failing to work?

Sorry to be a nay-sayer, but while you have stopped the problem occurring, I suspect the fix has affected the symptoms, not the cause.

If you have time, it may be worth running wireshark or similar and seeing what ntpd is doing on the network connection, I still think it may be trying to get out and failing....but as I said earlier, I am reaching the limits of my knowledge here, so take everything I say with a pinch of salt!


All times are GMT -5. The time now is 08:32 AM.