ntp init script

Bruce Dubbs bruce.dubbs at gmail.com
Mon Aug 23 12:34:26 PDT 2010

Jeremy Huntwork wrote:
> Hi,
> This has come up before, but I want to bring it up again now because 
> it's such a simple fix to an old problem.
> Given that the purpose of the init script is to (as the book puts it): 
> "run ntpd continuously and allow it to synchronize the time in a gradual 
> manner.", the current options passed to ntpd are incorrect.
> The init script currently uses 'ntpd -gqx'. The '-q' is the main 
> problem, since it means:
> "-q, --quit
>                Set the time and quit.
>                ntpd will exit just after the first time the clock is 
> set. This behavior mimics that of the ntpdate program, which is to be 
> retired."
> In this manner, nptd is never forked into the background, it only runs 
> once on boot. This also explains why the boot process will hang on ntpd 
> when there is no network connection - when using -q, the shell is 
> waiting for ntpd to finish and return.
> Simply removing the -q makes things work as expected, and is more in 
> harmony with the instructions here: http://www.pool.ntp.org/en/use.html

You are quoting out of context.  The fill startup is:

boot_mesg "Starting ntpd..."
ntpd -gqx
loadproc /usr/sbin/ntpd

ntpd -gqx slews the time to the current value and *then* starts the ntp 

Actually, Ive commented out 'ntpd -gqx' because, as you stated, if you 
don't have a network connection, the boot hangs for quite a while.  I 
don't think we've ever considered 'loadproc /usr/sbin/ntpd -gx' before.

I've been looking at ntp recently too.  Perhaps we should add the 
following to a client for /etc/ntp.conf.

# Don't answer queries from others
restrict default nomodify nopeer noquery

   -- Bruce

More information about the blfs-dev mailing list