Need help with Inky Phat crontab update


#1

I want to update the weather on my Inky Phat every 10 minutes.The directions to the Inky Phat say to enter, python weather.py, command after it is set up (which it does and works fine) and it says to add crontab -e
and then I add,
*/10 * * * * python /home/pi/Pimoroni/inkyphat/examples/weather.py
to that file that comes after that, but I must be doing something wrong as it never updates. Is there a code I can add to weather.py so it will update on its own? Or can someone tell me what I’m doing wrong.


#2

The file weather.py needs to load some images from the resources directory in /home/pi/Pimoroni/inkyphat/examples, so you need to write a little startup script for it that you call with Crontab:

Create your weather launcher:

cd ~
nano weather.sh
#!/bin/bash
cd /home/pi/Pimoroni/inkyphat/examples/
python weather.py

Ctrl+X, Y, Enter

Make it executable:

chmod +x weather.sh

Then your Crontab script should be changed to /home/pi/weather.sh

The cd part is crucial- it ensures that the working directory is changed so that weather.py can find the contents of /home/pi/Pimoroni/inkyphat/examples/resources


#3

I’m having the same issue/ question. Unfortunately, the workaround above doesn’t do the trick for me. What might I be doing wrong? And thanks!


#4

What code are you running, and which directory is it stored in?


#5

Hey, thanks for the reply! The crontab-code, you mean?

I pretty much opted for the above code in combination for a 10 mins refreshment rate as derived from the Inky Phat “Getting started” page. Also, I added a line to start up the weather app at every boot which so far is also failing. Here’s what I’ve entered into crontab -e:

@reboot python /home/pi/weather.sh

*/10 * * * * python /home/pi/weather.sh


#6

Note that “weather.sh” is a bash script, not a Python script. You shouldn’t need to call it with Python:

@reboot /home/pi/weather.sh

#7

Indeed, thank you for clearing that up. I removed the “python” and now it starts up like a charm… still no updates, though. Did I include any errors in the refreshment command line?

*/10 * * * * python /home/pi/weather.sh


#8

Yup- same issue, you need to drop python since it’s not a Python script.


#9

thank you so much for your patience with my novice-ness! this really does the trick now.