crontab python 脚本查询
crontab python script query
我在 Pi3 上有一个 python 脚本,它将传感器读数发送到 mysql 数据库,我想在启动时 运行。我在 crontab 中尝试了 @boot 的几种组合,但数据库 table 从未获得任何新数据。
脚本的第一行是...
#!/usr/bin/python
和脚本 运行s:
./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 对我不起眼的项目有什么影响?
尝试 python 的完整路径并写入日志以供调查:
@reboot /usr/bin/python /home/pi/distance2.py > /home/pi/distance2_cronjoblog 2>&1
我在 Pi3 上有一个 python 脚本,它将传感器读数发送到 mysql 数据库,我想在启动时 运行。我在 crontab 中尝试了 @boot 的几种组合,但数据库 table 从未获得任何新数据。
脚本的第一行是...
#!/usr/bin/python
和脚本 运行s:
./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 对我不起眼的项目有什么影响?
尝试 python 的完整路径并写入日志以供调查:
@reboot /usr/bin/python /home/pi/distance2.py > /home/pi/distance2_cronjoblog 2>&1