[英]How to start python file on startup using linux?
I have a python file that I want to start up automatically using raspberry pi.我有一个 python 文件,我想使用树莓派自动启动它。 I have searched this up a few times but have found either outdated answers or answers that are very unclear.
我已经搜索了几次,但发现了过时的答案或非常不清楚的答案。 Does anyone know of a solution?
有谁知道解决方案?
There are several ways to do so.有几种方法可以做到这一点。 I couldn't find anything on stackoverflow tho so here you go:
我在 stackoverflow 上找不到任何东西,所以这里是 go:
Using the "/etc/rc.local" is probably the quickest/easiest solution:使用“/etc/rc.local”可能是最快/最简单的解决方案:
You have to open rc.local and add whatever you want to execute on startup.您必须打开 rc.local 并添加您想要在启动时执行的任何内容。 In your case something like this:
在你的情况下是这样的:
sudo nano /etc/rc.local
须藤纳米 /etc/rc.local
then add the following to the end of the file然后将以下内容添加到文件末尾
sudo python /home/pi/python-program.py &
须藤 python /home/pi/python-program.py &
while "/home/pi/python-program.py" needs to point to your python program而“/home/pi/python-program.py”需要指向您的 python 程序
you can find more explanations and other methods here: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/#local你可以在这里找到更多的解释和其他方法: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/#local
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.