[ntp:questions] ntpd -gq VS ntpdate -B

Tom Smith smith at cag.zko.hp.com
Thu Apr 12 18:08:39 UTC 2007

> On Apr 11, 4:39 pm, Tom Smith <s... at cag.zko.hp.com> wrote:
>> "ntpdate -b" steps the time after doing a quick look at set of
>> candidates you have specified on the command line. It is what
>> is normally recommended for a boot sequence prior to starting ntpd.
>> "ntpdate -B" slews the time, but is otherwise the same. Not
>> usually recommended for a boot sequence because the initial
>> time setting isn't complete when it exits.
>> "ntpd -gq" uses all the convergence rules of the normal
>> ntpd against a list of servers specified in a separate
>> configuration file. After selecting a peer, it will either
>> step OR slew the time, depending on the magnitude of
>> the offset, and the time adjustment may or may not be
>> complete when it exits. It is not equivalent to either
>> "ntpdate -b" or "ntpdate -B".
>> ntpdate takes a few milliseconds to run (dependent on
>> network delays and timeouts) and sets the clock typically
>> within a few milliseconds of "correct" with respect to
>> the servers you have chosen to use. "ntpd -gq" takes a minimum
>> of a few seconds to reach convergence and produces about the
>> same practical level of accuracy. In steady state, ntpd,
>> of course, is much more accurate and less disruptive than
>> repeated use of ntpdate.
>> -Tom
> Thanks for your exhaustive explanation but I have also one doubt:
> If for example I used in cron "ntpdate -c server1 server2" (without
> taking accuracy but only convergence time) and local clock was
> different from NTP server time for 60 seconds, ntpdate will step time
> taking several hours ! How can it destructive ? Time will not adjust
> in few seconds but in several hours, I think.
> Ntpd -qg with this time difference has the same behavior. Do you agree
> with me ?
> See following reference of ntpdate manual:
> If  ntpdate determines  the  clock  is in error more than 0.5 second
> it will simply step the time by calling the system settimeofday()
> routine.  If the error is less than 0.5 seconds, it will slew the time
> by calling the system adjtime()  routine

I think you meant "-b" or -B", not "-c", but ....

Yes. ntpdate with NEITHER "-b" nor "-B" will do that. In that respect,
it is similar, but still not identical, to "ntpd -gq". However,
you were asking about "ntpdate -B", and ntpdate is most often
and most appropriately used as "ntpdate -b", which are the
slew-only and step-only variants, respectively.

If you are thinking about using ntpdate in any form in
cron, you should instead be thinking about using ntpd,
which is designed for continuous clock maintenance.
ntpdate is intended primarily for one-time corrections.


More information about the questions mailing list