The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
how to start things at boot time 5 December 1999
Need more help on this topic? Click here
This article has 1 comment
Show me similar articles
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.

Need more help on this topic? Click here
This article has 1 comment
Show me similar articles