0

I've created a cron job and it does seem to be running. This is the line I've put in cron file :

@reboot python /home/pi/Pimoroni/bme680/Indoor-Air-Quality-MQTT.py &

I ran the command grep CRON /var/log/syslog to get the list of cron tasks :

Dec  6 13:24:54 TBHPowerPaintPlant cron[327]: (CRON) INFO (pidfile fd = 3)
Dec  6 13:24:54 TBHPowerPaintPlant cron[327]: (CRON) INFO (Running @reboot jobs)
Dec  6 13:24:54 TBHPowerPaintPlant CRON[380]: (root) CMD (python /home/pi/Pimoroni/bme680/Indoor-Air-Quality-MQTT.py &)

The script itself contains a line to log to a file when it first runs and this log file is also empty. The script runs fine from the command prompt using python /home/pi/Pimoroni/bme680/Indoor-Air-Quality-MQTT.py Can anyone tell me what I need to do to this script to run on boot up?

Thanks

9
  • 1
    The script probably has a different home directory (possibly /root), You need to make sure that your script and any software it uses has the full path specified to any files/programs it uses.
    – joan
    Dec 6, 2017 at 14:03
  • So it should be python /root/home/pi/Pimoroni/bme680/Indoor-Air-Quality-MQTT.py? Dec 6, 2017 at 14:14
  • No. You need to google linux paths and understand the difference between absolute and relative paths.
    – joan
    Dec 6, 2017 at 14:17
  • From my understanding, home/pi is the user folder and is the full path? Should i move the script to another location to make sure. Is there a recommended location for running scripts on system startup? Dec 6, 2017 at 14:37
  • 5
    Possible duplicate of Cron not finding necessary files to run .py file Dec 6, 2017 at 18:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.