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 have a python program which I wrote and would like to run on startup in FreeBSD 7.1.

For my current installation, the script lives at /home/devuser/project/trunk/src/proj. At the beginning of my main in proj I have added (for testing)

os.system("echo 'proj STARTED' >> /tmp/projlog")

In /usr/local/etc/rc.d/ I have 'proj' which contains:

# PROVIDE: proj
# KEYWORD: shutdown
. "/etc/rc.subr"



load_rc_config $name
echo "trying to run proj" >> /tmp/rclog
run_rc_command "$1"

In my rc.conf:


If I run /usr/local/etc/rc.d/proj <start|stop|status> as root everything works as expected - proj runs, trying to run proj appears in /tmp/rclog, and proj STARTED appears in /tmp/projlog.

On system startup, I get trying to run proj in /tmp/rclog, but nothing in /tmp/projlog - python isn't being started.

Why is the rc script running but failing to actually invoke Python, and not giving me any feedback?

share|improve this question
up vote 3 down vote accepted

I'm guessing /usr/local/bin (or wherever the python binary resides in FreeBSD) doesn't exist in $PATH when running init scripts.

Try changing command_interpreter="python" to command_interpreter="/usr/local/bin/python".

Also, does the your file contain a shebang (with a correct path) and is executable?

share|improve this answer
Specifying the full interpreter path fixed it. Also, proj contained a shebang and correct path, but opened several subprocesses using Popen, which specified #!/usr/bin/env python` - rc didn't like this. Using #!/usr/local/bin/python instead has made everything start working. Thanks. – gdm Nov 25 '09 at 21:20

It's highly unlikely that python is in the path on boot up.

Try specifying the full path in your command_interpreter variable.

share|improve this answer

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.