RPi python script fails to run from: /etc/rc.local, crontab, systemd

久未见 提交于 2019-11-27 09:54:09

To run python script via /etc/rc.local:

1) Edit the file using sudo /etc/rc.local;

2) Add the following to the file right before exit 0:

(sleep 10;python /home/pi/Cigar-Box/CigarBox.py)&

The parentheses allows your to run multiple commands in the background. The sleep 10 will delay the running of script by 10 seconds, as some of the services that your script depend on may not be available yet at the time of booting rc.local.

Alternatively you can use crontab @reboot to automate the execution of your script.

Using crontab:

1) run command line sudo crontab -e;

2) add the command to the end of the file:

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