【发布时间】:2012-06-12 11:36:33
【问题描述】:
我面临以下问题。我想在 Ubuntu 11.10 系统上将 python 脚本作为服务运行(已在以下链接中提到: Python script as linux service/daemon)
我按照上述链接中提到的步骤进行操作,但我在 syslog 中收到以下错误消息:
init: script main process (21826) terminated with status 1
Jun 8 16:59:55 bilbo kernel: [263012.984531] init: script main process ended, respawning
Jun 8 16:59:55 bilbo kernel: [263013.044099] init: script main process (21827) terminated with status 1
以上两行一直在重复。
在说sudo start script 时,我得到以下信息:
$ sudo start script
script start/running, process 21826
以下是我script.conf的内容放在/etc/init中:
description "Used to start python script as a service"
author "bilbo"
start on runlevel [2]
stop on runlevel [06]
exec python /home/bilbo/scripts/webserver.py
respawn
请告诉我我做错了什么?我是否也必须更改我的 python 代码?
【问题讨论】:
-
cron环境路径中是否有python进程?尝试使用绝对路径 /usr/local/bin/python 或您使用的 python 所在的位置。
-
@TeemuIkonen:它不是由 cron 运行的。它正在使用init运行。 ... init 的路径中没有任何内容...
-
@Teemu Ikonen - 尝试使用 exec /usr/bin/python 文件名,但还是一样
-
在此处查看调试帮助upstart.ubuntu.com/cookbook/#exec 第 20.5 节。就我个人而言,我已经抛弃了 linux init mess 并切换到 supervisord
-
你能发布你的 Python 脚本内容吗?