我有一个我编写的Python程序,想在FreeBSD 7.1启动时运行。
对于我目前的安装,脚本位于/home/devuser/project/trunk/src/proj 。 在我的main proj我开始添加(testing)
os.system("echo 'proj STARTED' >> /tmp/projlog")
在/usr/local/etc/rc.d/我有'proj'其中包含:
#!/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"
在我的rc.conf中:
rc_debug="YES" proj_enable="YES"
如果以root /usr/local/etc/rc.d/proj <start|stop|status>运行/usr/local/etc/rc.d/proj <start|stop|status>一切都按预期运行 – proj运行, trying to run proj出现在/tmp/rclog ,并且proj STARTED /tmp/rclog出现在/tmp/projlog 。
在系统启动时,我trying to run proj在/tmp/rclog trying to run proj ,但没有在/tmp/projlog – python中没有启动。
为什么rc脚本正在运行,但是没有真正调用Python,而且没有给我任何反馈?
在运行init脚本时,我猜测/ usr / local / bin (或python二进制文件驻留在FreeBSD中的任何地方)在$PATH中不存在。
尝试将command_interpreter="python"更改为command_interpreter="/usr/local/bin/python" 。
另外,你的文件是否包含一个shebang (具有正确的path)并且是可执行的?
python在启动的path上是不太可能的。
尝试在command_interpretervariables中指定完整path。