LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-19-2010, 11:20 PM   #1
knappster
Member
 
Registered: Mar 2004
Posts: 175

Rep: Reputation: 30
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.
 
Old 01-20-2010, 03:04 AM   #2
jimbo1954
Member
 
Registered: Oct 2006
Location: High Wycombe, Bucks, UK.
Distribution: Debian and Fedora Core in equal measure
Posts: 264

Rep: Reputation: 33
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.
 
Old 01-20-2010, 03:16 AM   #3
minrich
Member
 
Registered: Aug 2003
Location: Isles of Man & Wight
Distribution: See signature
Posts: 548

Rep: Reputation: 40
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.
 
Old 01-20-2010, 07:22 AM   #4
knappster
Member
 
Registered: Mar 2004
Posts: 175

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by jimbo1954 View Post
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...
 
Old 01-20-2010, 08:08 AM   #5
jimbo1954
Member
 
Registered: Oct 2006
Location: High Wycombe, Bucks, UK.
Distribution: Debian and Fedora Core in equal measure
Posts: 264

Rep: Reputation: 33
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...
 
Old 01-20-2010, 07:23 PM   #6
knappster
Member
 
Registered: Mar 2004
Posts: 175

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by jimbo1954 View Post
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?
 
Old 01-20-2010, 07:53 PM   #7
JonathanWilson
Member
 
Registered: Aug 2009
Location: Ilkeston, England
Distribution: ubuntu, xp, embeded
Posts: 79

Rep: Reputation: 1
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.
 
Old 01-20-2010, 10:09 PM   #8
knappster
Member
 
Registered: Mar 2004
Posts: 175

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by JonathanWilson View Post
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.
 
Old 01-21-2010, 02:44 AM   #9
jimbo1954
Member
 
Registered: Oct 2006
Location: High Wycombe, Bucks, UK.
Distribution: Debian and Fedora Core in equal measure
Posts: 264

Rep: Reputation: 33
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.
 
Old 01-21-2010, 05:54 AM   #10
knappster
Member
 
Registered: Mar 2004
Posts: 175

Original Poster
Rep: Reputation: 30
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.

Last edited by knappster; 01-21-2010 at 08:12 AM.
 
Old 01-21-2010, 09:14 AM   #11
jimbo1954
Member
 
Registered: Oct 2006
Location: High Wycombe, Bucks, UK.
Distribution: Debian and Fedora Core in equal measure
Posts: 264

Rep: Reputation: 33
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
 
Old 01-21-2010, 12:12 PM   #12
knappster
Member
 
Registered: Mar 2004
Posts: 175

Original Poster
Rep: Reputation: 30
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.
 
Old 01-27-2010, 01:43 PM   #13
knappster
Member
 
Registered: Mar 2004
Posts: 175

Original Poster
Rep: Reputation: 30
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!
 
Old 01-27-2010, 01:56 PM   #14
minrich
Member
 
Registered: Aug 2003
Location: Isles of Man & Wight
Distribution: See signature
Posts: 548

Rep: Reputation: 40
You are welcome
 
Old 01-28-2010, 04:25 AM   #15
jimbo1954
Member
 
Registered: Oct 2006
Location: High Wycombe, Bucks, UK.
Distribution: Debian and Fedora Core in equal measure
Posts: 264

Rep: Reputation: 33
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Debian Lenny: Letting a network-time server manage your clock LXer Syndicated Linux News 0 12-31-2009 03:00 AM
Time drift Vmware dreamlemon Debian 7 11-25-2009 02:25 PM
Linux Time Drift Samgari Linux - Server 2 08-19-2009 07:59 PM
How to fix severe clock drift in FC3? rylan76 Linux - Software 1 07-03-2005 11:37 AM
Dell Laptop time drift rockdw Linux - Hardware 0 01-31-2003 06:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration