Upstart python script

心已入冬 提交于 2019-12-11 10:07:26

问题


I need to run code located /home/pi/Hello_on_startup.py each time RaspberryPi restarts

For that I created hello.conf file in /etc/init/ directory

description "A script controlled by upstart"
author "Anton"

start on runlevel [2345]
stop on runlevel [016]

respawn

exec /home/pi/Hello_on_startup.py`

When I run command sudo start hello I get an answer Unknown job: hello


回答1:


You need a script...end script block in your conf file for it to be recognised, as shown here. Your resulting hello.conf file would look as follows:

description "A script controlled by upstart"
author "Anton"

start on runlevel [2345]
stop on runlevel [016]

respawn

script
    exec /home/pi/Hello_on_startup.py`
end script

There is also a similar question on AskUbuntu.



来源:https://stackoverflow.com/questions/34814357/upstart-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!