Upstart python script

2019-08-10 20:37发布

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条回答
别忘想泡老子
2楼-- · 2019-08-10 21:17

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.

查看更多
登录 后发表回答