Jump to content

ntpd not keeping system time accurate


ffrr
 Share

Recommended Posts

I have been running ntpd, and after booting up, the time is correct, but by the end of the day, it can be 10 minutes or more fast.

 

I thought ntpd was supposed to regularly fix the time, and adjust it so it runs closer to actual. How often does it adjust the time, and can I control this?

 

Maybe it's because of the uneven load I put on the machine, sometimes playing or converting video, but other times doing nothing? Would I be better off not usind ntpd and just scheduling ntpdate in a cron job every hour?

 

 

(running Mandriva 2006 LE)

Link to comment
Share on other sites

scheduling ntpdate via cron every hour or maybe every 30 min. is a good idea.. just make sure you got the correct ntp server pool

 

It's just that I would have to turn the ntpd off, because with it running I get

 

3 Aug 10:51:12 ntpdate[13872]: the NTP socket is in use, exiting

 

from ntpdate.

Link to comment
Share on other sites

yeah, maybe you should turn that off, you only need it if you want it to serve as time server.. say you have other PCs on your network and you want their time to be sync on that BOX..or you want to join the NTP server pool.. but if not... then you may turn it off.. then let the ntpdate do the job

Link to comment
Share on other sites

Note that by default, ntpd log messages are written to /var/log/messages.

 

To see what ntpd is doing and what adjustments are being made and when, execute the following command as the root user in a terminal:

 

cat /var/log/messages | grep ntpd

 

This may help you diagnose what's going on.

 

Here's some sample output from mine:

 

Aug  1 17:44:08 ntpdate[5308]: step time server 128.194.254.9 offset -6.097146 sec
Aug  1 17:44:08 ntpd:  succeeded
Aug  1 17:44:08 ntpd[5322]: ntpd 4.2.0@1.1161-r Wed Sep  7 20:06:56 CEST 2005 (1)
Aug  1 17:44:08 ntpd: ntpd startup succeeded
Aug  1 17:44:08 ntpd[5322]: precision = 1.000 usec
Aug  1 17:44:08 ntpd[5322]: kernel time sync status 0040
Aug  1 17:44:08 ntpd[5322]: frequency initialized -8.896 PPM from /etc/ntp/drift
Aug  1 17:47:22 ntpd[5322]: synchronized to LOCAL(0), stratum=10
Aug  1 17:47:22 ntpd[5322]: kernel time sync disabled 0041
Aug  1 17:48:26 ntpd[5322]: kernel time sync enabled 0001
Aug  1 17:52:46 ntpd[5322]: synchronized to 128.194.254.9, stratum=2
Aug  1 18:10:07 ntpd[5322]: time reset -0.161913 s
Aug  1 18:14:24 ntpd[5322]: synchronized to LOCAL(0), stratum=10
Aug  1 18:19:46 ntpd[5322]: synchronized to 128.194.254.9, stratum=2
Aug  1 18:40:16 ntpd[5322]: time reset -0.348388 s
Aug  1 18:44:33 ntpd[5322]: synchronized to LOCAL(0), stratum=10
Aug  1 18:49:54 ntpd[5322]: synchronized to 128.194.254.9, stratum=2
Aug  1 19:04:56 ntpd[5322]: time reset +0.153221 s
Aug  1 19:09:12 ntpd[5322]: synchronized to LOCAL(0), stratum=10
Aug  1 19:14:35 ntpd[5322]: synchronized to 128.194.254.9, stratum=2
Aug  1 19:28:41 ntpd[5322]: time reset +0.284179 s

 

There's a great site for ntp documentation here:

 

http://ntp.isc.org/bin/view/Main/DocumentationIndex

Link to comment
Share on other sites

Note that by default, ntpd log messages are written to /var/log/messages.

 

To see what ntpd is doing and what adjustments are being made and when, execute the following command as the root user in a terminal:

 

cat /var/log/messages | grep ntpd

 

This may help you diagnose what's going on.

 

Here's some sample output from mine:

 

 

 

There's a great site for ntp documentation here:

 

http://ntp.isc.org/bin/view/Main/DocumentationIndex

 

Yes I am not getting any time resets. See..

 

Aug 3 08:13:58 localhost ntpd: ntpd startup succeeded

Aug 3 08:13:58 localhost ntpd[13439]: precision = 3.000 usec

Aug 3 08:13:58 localhost ntpd[13439]: kernel time sync status 0040

Aug 3 08:13:58 localhost ntpd[13439]: frequency initialized -192.077 PPM from /etc/ntp/drift

Aug 3 08:17:12 localhost ntpd[13439]: synchronized to LOCAL(0), stratum=10

Aug 3 08:17:12 localhost ntpd[13439]: kernel time sync disabled 0041

Aug 3 08:18:17 localhost ntpd[13439]: kernel time sync enabled 0001

Aug 3 11:02:52 localhost ntpd[13439]: ntpd exiting on signal 15

Aug 3 11:02:52 localhost ntpd: ntpd shutdown succeeded

 

Nearly 3 hours between 08:18 and 11:02, with nothing happening

Link to comment
Share on other sites

Is the system Linux-only, or dualboot?

If it also boots windows, then the time should be set to localtime, and not UTC.

 

Not dual booot. Won't have Windows ever again :-)

 

Seriously, the time is correct after booting up, but the clock gains time continually while it is running. As I posted above, the ntpd was not doing ANY corrections.

 

I am currently running ntpdate every half hour in a cron job - at least that works.

Link to comment
Share on other sites

Try my recently made howto here:

 

https://mandrivausers.org/index.php?showtopic=33672

 

it could be that your /etc/ntp.conf isn't configured correctly, which is why it's not synchronising.

 

I thought that too, but it looks OK.

 

Here it is

#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
server	127.127.1.0	# local clock
fudge	127.127.1.0 stratum 10	

server ntp.adelaide.edu.au
#server pool.ntp.org
#server pool.ntp.org
#server pool.ntp.org

#
# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift
multicastclient			# listen on default 224.0.1.1
broadcastdelay	0.008

#
# Keys file.  If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key number to be
# used for making requests.
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote
# systems might be able to reset your clock at will.
#
#keys		/etc/ntp/keys
#trustedkey	65535
#requestkey	65535
#controlkey	65535

#restrict default ignore

Link to comment
Share on other sites

Looks fine yeah for the desktop-side. If you right-click the clock and choose adjust/date time and enter root password when prompted, does it show the adelaide mirror as well?

 

Hopefully it does, that should confirm even more that it's set up correctly within KDE also.

Link to comment
Share on other sites

Looks fine yeah for the desktop-side. If you right-click the clock and choose adjust/date time and enter root password when prompted, does it show the adelaide mirror as well?

 

Hopefully it does, that should confirm even more that it's set up correctly within KDE also.

 

It used to (that's where I set it in the first place), but as I said a bit earlier in the thread, I've turned off ntpd so I can use ntpdate in a cron job to keep the time straight.

 

The problem has never been contacting and getting the time from a time server. It did this the first time I set it using KDE clock. I fact, even later, if I switched to a new time server, it would fix up the clock - but once only. It is the periodic fixes after that, that it never did. ntpd just sat there letting the time get out of whack from then on.

Edited by ffrr
Link to comment
Share on other sites

Try adding this line to your config:

 

restrict ntp.adelaide.edu.au mask 255.255.255.255 nomodify nopeer notrap

 

just under the server ntp.adelaide line, and see if it helps make a difference. Alternatively, the line could be this:

 

restrict ntp.adelaide.edu.au mask 255.255.255.255 nomodify notrap noquery

 

if the first line doesn't work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...