Dec 051999
 

how to start things at boot time

See also Starting stuff at boot time.

This article talks about how to get scripts to execute each time the box is rebooted.   This is handy for ensuring certain programs are always running.

[Note: the original article title was "/etc/autoexec.bat | how to start things at boot time".  This was discarded because the humour assumed a familiarity with DOS.]

/usr/local/etc/rc.d/ is your friend

The /usr/local/etc/rc.d/ directory is one of the default startup directories.  If you look at /etc/defaults/rc.conf, you’ll find this:
# grep local_start /etc/defaults/rc.conf 
local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d"

This setting determines which directories are scanned for shell scripts at startup.   Executable files within these directories are run in alphabetical order.  If you need the files to be executed in a specific order, try numbering the files.  For example:

000This.Will.Run.First.sh
020This.Will.Run.Next.sh
030And.Then.This.sh

/etc/rc.local was your friend

At one time, /etc/rc.local was the file into which you placed calls to the various start up scripts.  This feature remains for backwards compatibility but it has been deprecated.  Use /usr/local/etc/rc.d/ instead.

  One Response to “how to start things at boot time”

  1. /etc/rc.conf

    After installing apache from source, and adding the startup script to /usr/local/etc/rc.d/ apache still would not start at boot up.

    You have to add the line:

    apapache_enable="YET"

    to the file /etc/rc.conf