I need to run a command at startup on my machine using FreeBSD:
cd /home/portal
mv portal.sqlite corrupt_portal.sqlite
This is clearly not a daemon or a service, just a one time command at every boot.
I tried to put a .sh file inside /usr/local/etc/rc.d/ with #!/bin/bash
and it doesn't do anything, I also tried to simply write touch testfile
If I run both versions manually they work with no problem.
What am I missing here?
Best Answer
The rc(8) script is responsible for running the automatic boot process, and the example section of the manual gives a simple template for the
/etc/rc.d/
directory. Read the rc.subr(8) manual page for further guidance on writing startup scripts.However, one of the final stages of the automatic boot process is to read a script file called
/etc/rc.local
(if it exists). This file requires no special formatting or keywords, or the execute bit set.From the
rc(8)
manual page: