1

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:

#!/bin/sh
# PROVIDE: proj
# REQUIRE: DAEMON LOGIN
# KEYWORD: shutdown
. "/etc/rc.subr"

$location="/home/devuser/project/trunk/src"

name="proj"
rcvar=`set_rcvar`
command="$location/$name"
command_args="$1"
command_interpreter="python"

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

In my rc.conf:

rc_debug="YES"
proj_enable="YES"

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?

2 Answers 2

4

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?

1
  • 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, 2009 at 21:20
1

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

Try specifying the full path in your command_interpreter variable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .