[英]Upstart python script
I need to run code located /home/pi/Hello_on_startup.py each time RaspberryPi restarts 每次重新启动RaspberryPi时,我都需要运行位于/home/pi/Hello_on_startup.py的代码
For that I created hello.conf file in /etc/init/ directory 为此,我在/ etc / init /目录中创建了hello.conf文件。
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 当我运行命令sudo start hello时,我得到一个答案未知作业:hello
You need a script...end script
block in your conf file for it to be recognised, as shown here . 你需要一个
script...end script
在你的conf文件块为它被认可,如图所示这里 。 Your resulting hello.conf
file would look as follows: 生成的
hello.conf
文件如下所示:
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 . AskUbuntu上也有类似的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.