View Single Post
  #1   (View Single Post)  
Old 18th February 2019
hanzer's Avatar
hanzer hanzer is offline
Real Name: Adam Jensen
just passing through
Join Date: Oct 2013
Location: EST USA
Posts: 314
Default How to execute a command at system startup

My FreeBSD system needs to execute a couple simple commands sometime during or shortly after the boot process. After a bit of searching, it seems many people have this need and there doesn't seem to be a canonical solution. There is much written about managing services (daemons) but learning the details of rc.d scripting in order to execute a command (# camcontrol apm 0:0:0 -l 250) seems like [s]a dirty[/s] an absurd hack. The rc man page says:
The rc.local script contains
commands which are pertinent only to a specific site. Typically, the
/usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but
if you want to use rc.local, it is still supported. In this case, it
should source /etc/rc.conf and contain additional custom startup code for
your system. The best way to handle rc.local, however, is to separate it
out into rc.d/ style scripts and place them under /usr/local/etc/rc.d/.
This is the only information I could find about /etc/rc.local (was this vague, sentimental man page blurb written by a child?). If anyone here is familiar with rc.local syntax and its use within the FreeBSD rc system, if you could post a simple, best practices example of a working script, that would be very helpful!
Reply With Quote