-1

I have task to synchronyze linux device with ntp server. Documentation said that by default ntpd check the difference between system time and server time, and if offset is within panic threshold(1000s be default) ntpd begin slowly correction of system time. Ok, that's good for me, I need that behaviour.

I set system time manually and then start ntpd. Using command ntpq -c peers I can look for synchronization process. It show that device linking to server and get packets. But after minute or two system time changed with one big step to server time. And this is bad in my situation, I need slowly correction. I have no working ideas why is it so!!!

I tried this with different servers and linux mashines, everything the same.

Device based on raspberry pi 2, linux image build with buildroot.

# ntpd --version
ntpd 4.2.8p2@1.3265-o Fri Jul 29 11:57:46 UTC 2016 (1)
#
# uname -a
Linux buildroot 3.18.12-v7 #3 SMP PREEMPT Thu May 12 17:53:44 MSK 2016 armv7l GNU/Linux
#
# cat /etc/ntp.conf
server 10.0.0.111 #my local server
driftfile /etc/ntp.drift
logfile /var/log/ntp/ntp.log
restrict 10.0.0.111 nomodify noquery #ban any packets from server, which send to modify local time

I can't find any explanation about this. All quiestions is about how quickly synchronyze time on daemon start, but I need opposite.

So, have no idea.....

yankovic
  • 1
  • 3

2 Answers2

6

By default, ntpd will step (instead of slew) the time if the offset is greater than 128ms. You can avoid that with the -x command line option, but beware: Correcting one second of offset will take about 2000secs, so this can take a long time.

 -x    Normally, the time is slewed if the offset is less than the step 
       threshold, which is 128 ms by  default,  and  stepped  if
       above  the  threshold.  This option sets the threshold to 600 s, 
       which is well within the accuracy window to set the clock
       manually.  Note: Since the slew rate of typical Unix kernels is 
       limited to 0.5 ms/s, each second of adjustment requires an
       amortization  interval of 2000 s.  Thus, an adjustment as much as 600 s 
       will take almost 14 days to complete.  This option
       can be used with the -g and -q options.  
       Note: The kernel time discipline is disabled with this option.
Sven
  • 98,649
  • 14
  • 180
  • 226
1

For one-shot time sync, you can use two different methods/protocols:

  • ntpdate uses the SNTP protocol, and it is very fast
  • ntpd -q uses the NTP protocol and, albeit slower, it is more accurate.
shodanshok
  • 47,711
  • 7
  • 111
  • 180
  • No, I don't need obe-shot time sync. I need slowly correction with default 0.128s steps immediatly after ntpd start. But in practise, daemon make one big step and system time become equl to server time. By documentation, the behavior like I need is set by default, but it not! – yankovic Aug 10 '16 at 07:01