This is how you use the built-in rc utility, that controls the automatic boot process, to run a script at boot time in FreeBSD.

rc controls the automatic boot process.

If you want to run a script at boot time in FreeBSD, then you can let rc execute it. rc is a built-in utility, that controls the automatic boot process. The manual has a detailed description of its configuration files and features.

# man rc

This kind of old-style shell scripts should be placed in the following directory, where they will executed in alphabetical order.

/usr/local/etc/rc.d

The script must match the globbing pattern *.sh and have the executable file mode set. If the script depends on third party applications, that has executable files in /usr/local/bin, then you use the full path. If the script depends on internet connection or network, you might want to make it test and wait a limited amount of time for networks to get ready, before it proceeds.

Example of how to run a script at boot time.

In the following example I create a shell script, that rc will execute at boot time.

# cd /usr/local/etc/rc.d
# nano myscript.sh
# chmod 0755 myscript.sh

More about FreeBSD.

You can see more of my posts about FreeBSD in my FreeBSD category.