Startup script

Jerry McAllister jerrymc at
Sun Feb 26 19:04:41 PST 2006

> Hi all,
> newbie question: which script do I put stuff that needs to be booted  
> during system startup, like apache httpd, spamd, named, etc?

First of all, you should put a separate script for each utility to start
in the  /usr/local/etc/rc.d/  directory.   Many of these utilities do
that for you automatically when you install them through the ports system.

The script should be written to accept at least start|stop as arguments.  
When the system boots, it attempts to run every script in that directory, 
I believe in standard sort order and gives each the 'start' argument.
Then when the shutdown is run, it runs each with the 'stop' argument.

To qualify for execution, the sctipt name must end in '.sh' and it must
have execute persission.

Some of them must be activated by putting a line in the /etc/rc.conf.local
file (or just /etc/rc.conf if you prefer but I don't like to clutter it
up too much) to set an appropriate environment variable.   Most of them 
are in the form of something like
or similar.  Check the script and the utility documentation to see what
sort of environment variable must be set.   The script checks for whatever
environment variable it wants to when it runs to see what it should do.

A very old fashioned and currently unsupported way was to put a command
in the /etc/usr.local file, but that is no longer a good way to do it.


> Joacim

More information about the freebsd-questions mailing list