LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-11-2011, 09:55 PM   #1
vivaystn
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Rep: Reputation: 0
How to adjust the next update in NTP?


Hi!
I have a problem in configuring ntp client. I want to synchronize with remote server in every second or minute. I configured ntp.conf but I didn't figure out how I can change the delay update. The ntpq -p shows the following, where the next update is after 10. Could you tell me the measure used. 10 what? And how I can adjust that?



Quote:
remote refid st t when poll reach delay offset jitter
==============================================================================
193.95.63.229 LOCAL(0) 3 u 10 64 1 20.273 -298125 0.001
Thank's
 
Old 05-12-2011, 06:50 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,381

Rep: Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650
when is defined as sec/min/hr since last received packet and is not adjustable. The poll time is adjustable with the min value being 64 and the max 1024 seconds. If the server in your post is the only one listed in your ntp.conf file your client will never sync to it since the offset is greater then 1000 seconds. Basically ntp will compensate for clock drift and once stabilized will automatically adjust the poll time.

As a side note what linux distribution/ version are you running?

Last edited by michaelk; 05-12-2011 at 06:59 AM.
 
Old 05-12-2011, 10:56 AM   #3
vivaystn
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 0
In fact I have a time stamp project, so the time must be accurate and any manual change (By hacker for example) must be fixed rapidly. I can do that by ntpdate in cron and that permit a refresh on each minute or using ntp client.
However, ntp client doesn't work in the right manner. According to the last comment when is always less than poll which is not the case. In addition, when I change the time (date -s hh:mm:ss) with less than 1000 s difference, the adjustment did not happen in the next 64s.
I use ubuntu 10.10 and this is my ntp.conf file if needed:
Quote:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
#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.ubuntu.com
server ntp.certification.tn

logfile /var/log/ntp.log

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 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
#broadcast 127.0.0.1
#broadcastdelay 0.008
# 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
Thank's for help
 
Old 05-12-2011, 07:08 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,381

Rep: Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650
Correction I posted the default values. The polling range is from 16 seconds (4) and 1.5 days (7).
ntp does not necessarily perform a time jump. If the offset is <128ms it will set the correct time otherwise it will slew the clock frequency to speed up or slow down. When ntpd first starts it will set time to any value without restrictions once. Otherwise it will update time as posted.

Whereas ntpdate will set the clock once it does not provide for any drift compensation. If your application does not mind absolute time jumps then nptdate via cron might be the best choice.

http://www.ntp.org/ntpfaq/NTP-s-algo.htm
 
Old 05-13-2011, 08:54 AM   #5
vivaystn
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you michaelk
But I have a little more question. Is there a way to force NTP to perform a time jump? How we can change the polling value?

For those who want to use a script and execute it regularly (each minute) using cron, this is mine. Enjoy!

Code:
GOON=1
while [ $GOON -ne 59 ]; do
GOON=`expr $GOON + 1 `
/usr/sbin/ntpdate -b ntp.certification.tn
sleep 1
done
 
Old 05-13-2011, 09:16 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,381

Rep: Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650Reputation: 1650
To change the minpoll value add the following to the ntp.conf file.
minpoll 4 (2^x i.e. 16 seconds, values range from 4 to 10)
maxpoll 4

This will force ntp to always poll and 16 seconds. npt is not designed to update with a time jump except at initial start up. Curious why you expect someone or something to change time.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ntp drift file in /etc/ntp instead of /var/lib/ntp - suggestion for a patch in Slack niels.horn Slackware 16 05-07-2009 07:35 PM
Day Light Saving update in the NTP talat Linux - Software 9 05-29-2008 09:52 AM
ntp client update time from windows ? minhsys Linux - Server 2 02-26-2007 02:31 AM
NTP force update charlest Red Hat 2 07-26-2006 07:29 PM
Cannot update NTP behind firewall erikm103 Linux - Software 1 12-12-2003 02:36 PM


All times are GMT -5. The time now is 09:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration