Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to run a script when FreeBSD boots. I tried symlinking to it from /usr/local/etc/rc.d, but the script itself ( uses paths such as ./ These don't resolve correctly when invoked from /usr/local/etc/rc.d.

What would a simple script look like that would start and allow it's use of dot characters to correctly resolve to the script's own directory rather than /usr/local/etc/rc.d?

share|improve this question
up vote 2 down vote accepted
cd /actual/path/to/script

On top of your script?

Or you could add your script to /etc/rc.local. That way the script will run form it's current location and you would not have to worry about the path.

/etc/rc.conf is normally a file that contains loads of variables, but you can call commands to run at runtime also. Just add your script at the bottom.


More info: FreeBSD Handbook

share|improve this answer
hmm... i can't edit the target script unfortunately. Is there an easy way to create a wrapper? – ralph Apr 8 '11 at 9:47
Edited my post. – Bart De Vos Apr 8 '11 at 9:53
I tried symlinking to the script from /usr/local/etc/rc.d but it can't resolve paths in ./xxx format. I can't copy the script into /usr/local/etc/rc.d or the same thing will happen. – ralph Apr 8 '11 at 10:12
Sorry, brainfart... Edit above – Bart De Vos Apr 8 '11 at 10:16
cool, thanksss. – ralph Apr 8 '11 at 11:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.