本文介绍了新贵python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每次 RaspberryPi 重新启动时,我都需要运行位于 /home/pi/Hello_on_startup.py 的代码
为此,我在 /etc/init/ 目录中创建了 hello.conf 文件
description "一个由暴发户控制的脚本"作者安东"从运行级别开始 [2345]在运行级别停止 [016]重生exec/home/pi/Hello_on_startup.py`
当我运行命令 sudo start hello 我得到一个答案 Unknown job: hello
解决方案
您的 conf 文件中需要一个 script...end script
块才能被识别,如图所示 此处.您生成的 hello.conf
文件如下所示:
description "一个由暴发户控制的脚本"作者安东"从运行级别开始 [2345]在运行级别停止 [016]重生脚本exec/home/pi/Hello_on_startup.py`结束脚本
AskUbuntu上也有类似的问题.>
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
解决方案
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.
这篇关于新贵python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!