Notes on the /etc/rc.local FileThe resource configuration script /etc/rc.local was described earlier in this chapter simply as being obsolete. Administrators who used earlier versions of FreeBSD or certain Linux distributions will recognize this file. Its purpose is much the same as the /usr/local/etc/rc.d directoriesto provide you with a mechanism to extend the system's startup behavior by adding your own daemons or ad-hoc configuration changes. The rc.d method described earlier in this chapter is the best way to run a daemon or perform some automated task upon startup. However, in some cases (such as mounting a remote server or starting a backup client), it's more expedient to have a place where you can simply execute a command line without worrying about the careful structure of the proper resource configuration system. That's what /etc/rc.local is for (although it doesn't exist in the default installation). You can create the file (with the proper interpreter line modeled after the other rc.* files) and put any set of shell commands into it, and it will be executed just before the rc.d scripts. Support for rc.local is for backward-compatibility only, and it may eventually be removed from FreeBSD. To make sure your system supports it, check in /etc/rc.d for the existence of the local launch script, as excerpted in Listing 14.3. Listing 14.3. Excerpt from /etc/rc.d/local Showing Support for /etc/rc.local
If this file exists, you can use rc.local to launch your ad-hoc commands at startup. If you can, though, it is still a much better idea to use the rc.d script method. |