inkyPhat Crontab


#1

This InkyPhat is a really cool device. However, Crontab won’t run it for some reason. I have it currently set up to run every 1 minute and at reboot. This is just to test it out, I’ll eventually set it to every 10 minutes. This is sudo’s crontab:

*/1 * * * * python /home/pi/Pimoroni/inkyphat/examples/weather.py

@reboot python /home/pi/Pimoroni/inkyphat/examples/weather.py

I suspect crontab doesn’t know how to look in the /resources file for the backdrop.png file because if I run from my shell:

$ sudo python /home/pi/Pimoroni/inkyphat/examples/weather.py

it tells me:

IOError: [Errno 2] No such file or directory: ‘resources/backdrop.png’

Can anyone help me correct this please?


#2

You’re right. The issue is one of context, crontab is not running weather.py in the directory /home/pi/Pimoroni/inkyphat/examples/, and so the Python script can’t find any of its resources (in this case, backdrop.png)

You need to ensure the script is run in the right directory, which you can do by preparing a simple launcher script to run it:

nano /home/pi/weather.sh >

#!/bin/bash

cd /home/pi/Pimoroni/inkyphat/examples/
python weather.py

Then your crontab entry should be */1 * * * * bash /home/pi/weather.sh