ntpd with flags in rc.conf

Alex Zbyslaw xfb52 at dial.pipex.com
Wed Oct 11 11:07:34 PDT 2006

Zbigniew Szalbot wrote:

> I read this in the handbook:
> To ensure the NTP server is started at boot time, add the line 
> ntpd_enable="YES" to /etc/rc.conf. If you wish to pass additional 
> flags to ntpd(8), edit the ntpd_flags parameter in /etc/rc.conf.
> Now, I understand that the additional flag may be for example pid (-p 
> /var/run/ntpd.pid).
> So how do I put that flag in /etc/rc.conf where I have ntpd_enable="Yes"?
Firstly, you should check what default flags there are already.  For 90% 
of apps the defaults will be right for you.  Look in 
/etc/defaults/rc.conf for ntpd_flags and you find:

ntpd_flags="-p /var/run/ntpd.pid -f /var/db/ntpd.drift"

In many instances, the right thing is to *add* to rather than replace 
the default flags.  Let's say you wanted to add a "-g" to the default 
flags for ntpd_flags:

ntpd_flags=${ntpd_flags} -g

That way, if the default flags need to change for some reason, you still 
keep up with the defaults and just add your own local customisation.  If 
you cut-and-paste the default value out of /etc/defaults/rc.conf  then 
you may not notice when that value changes.


PS rc.conf is just a shell script, so all variable assignments follow 
the rules you can find in "man sh".  Don't put anything too clever in 
there, though, as this file is read many, many times when the system 
starts up (once per /etc/rc.d/* file at least) so anything like an echo, 
for example, will be executed many times.

More information about the freebsd-questions mailing list