我在Pi3上有一个python脚本,它将传感器读数发送到mysql数据库,我希望在启动时运行该数据库。我在crontab中尝试了@boot的几种组合,但数据库表从未获得任何新数据。
剧本的第一行是。。。
#!/usr/bin/python
脚本运行时使用:
./distance2.py
@reboot /home/pi/distance2.py &
# @reboot cd /pyhome/pi/Pimoroni/VL53L1X/Examples && sudo python distance2.py
# @reboot /home/pi/Pimoroni/VL53L1X/Examples/distance2.py &
(为了简单起见,我从Pimoroni目录中删除了脚本。)
从终端运行时,脚本工作正常:
pi@raspberrypi:~ $ ./distance2.py
distance.py
Display the distance read from the sensor.
Uses the "Short Range" timing budget by default.
Press Ctrl+C to exit.
VL53L1X Start Ranging Address 0x29
VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID :
ProductRevisionMajor : 1
ProductRevisionMinor : 15
Distance: 0mm
(1L, 'record inserted.')
Distance: 60mm
(1L, 'record inserted.')
Distance: 60mm
grep显示它运行正常(除非脚本名文本的红色表示有什么不好的地方?)
ps aux | grep distance2.py
pi 1530 0.0 0.5 7332 2032 pts/0 S+ 16:20 0:00 grep --color=auto distance2.py
crontab@boot对我卑微的项目有什么不满?