LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to adjust the next update in NTP? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-adjust-the-next-update-in-ntp-880211/)

vivaystn 05-11-2011 09:55 PM

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

michaelk 05-12-2011 06:50 AM

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?

vivaystn 05-12-2011 10:56 AM

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

michaelk 05-12-2011 07:08 PM

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

vivaystn 05-13-2011 08:54 AM

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


michaelk 05-13-2011 09:16 AM

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.


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