[英]crontab not running python script for Rpi.GPIO
我有一个python脚本,我正在尝试使用以下命令在启动时运行
sudo crontab -e
使用以下命令
@reboot python /usr/local/sbin/ShutdownJumper.py
脚本ShutdownJumper.py开头为:
#!/usr/bin/env python
#note crontab for superuser required a new PATH variable as here https://unix.stackexchange.com/questions/43392#answer-43394
import subprocess
try:
import RPi.GPIO as GPIO
except RuntimeError:
print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script")
重新启动RPi时,我会收到以下电子邮件:
Traceback (most recent call last):
File "/usr/local/sbin/ShutdownJumper.py", line 4, in <module>
import RPi.GPIO as GPIO
ImportError: No module named RPi.GPIO
尝试在crontab上使用此代码
@reboot cd /usr/local/sbin && sudo python ShutdownJumper.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.