问题描述
我尝试使用start-stop-daemon启动python脚本:
I'm trying to start python script with start-stop-daemon:
sudo /sbin/start-stop-daemon --start --pidfile /home/loop.pid \
--user www-data --group www-data -b --make-pidfile --chuid www-data \
--exec /usr/bin/python /home/loop.py --verbose
但没有python脚本。我做错了什么?
but no python script in my processes. What i do wrong?
loop.py:
import time
while True:
print "working..."
time.sleep(3)
推荐答案
我试过你的脚本和命令行,它正在我的机器上工作。您确定脚本位于 /home/loop.py
?
I tried your script and command line, and it is working on my machine. Are you sure your script is located at /home/loop.py
?
此外,请参阅这些打印,因为您指定 -b
(background)选项,因此该过程将从您的终端分离。尝试运行它而不使用 -b
进行测试,然后可以使用 -stdout
选项:
Also, don't expect to see those prints, because you are specifying the -b
(background) option, so the process is being detached from your terminal. Try running it without the -b
for testing purposes and then you can redirect the standard output to a logfile with the -stdout
option:
sudo /sbin/start-stop-daemon --start --pidfile /home/loop.pid \
--user www-data --group www-data -b --make-pidfile --chuid www-data \
--exec /usr/bin/python /home/loop.py --verbose -stdout /var/log/loop.log
这篇关于start-stop-daemon和python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!