Unix System Administration
How to execute a script during boot up on FreeBSD?
Having FreeBSD to execute a script during boot up is not complicated at all. There are several reasons to want to run a custom script when you start FreeBSD, such as mounting samba shares with spaces in their names (which are not compatible with the fstab file). To begin with, you need to have a shell script ready. If you don't yet, let's create it in the /usr/local/etc/rc.d/ directory as root:
$ su - # cd /usr/local/etc/rc.d/ # vi myscript.sh
Now, put some code into your shell script:
#!/bin/sh # This shell script is a test and will paste a "test.txt" file on my desktop echo 'Test' > ~charles/Desktop/test.txt chown charles:charles ~charles/Desktop/test.txt
Now, let's make this shell script executable:
# chmod +x myscript.sh
The only thing we have to do now is tell FreeBSD to execute this shell script at bootup:
# vi /etc/rc.conf
Add the following line of code to the rc.conf file:
myscript_enable="YES"
Save. Restart FreeBSD. You should see a test.txt file on your desktop :)
Tags: -
Related entries:
Last update: 2008-09-01 05:53
Author: Charles A. Landemaine
Revision: 1.1
You cannot comment on this entry