Crontab in Raspberry not working for refreshing website

372 Views Asked by At

This is my short but effective code:

#!/bin/bash

xdotool search –class midori key F5

The code's name is refresh.sh, and I've chmod'ed it. Also, when I run the code from the terminal, it works just as it should. However when I expect cron to run it, nothing seems to happen. The code is located on the Raspberries desktop: and this is what the cron request looks like:

* * * * * /home/pi/Desktop/refresh.sh

Additionally, I've copied and pasted the above full directory to the terminal, and the code works fine.

I don't know what else to do?

Question: How can I make the cron work?


Quickfix: One quick fix is doing a while true loop with a sleep function of 60 seconds and just run it, and leave it... but this isn't the 'ethical' solution. So then the code would look something like this:

#!/bin/bash

while true
do
  xdotool search –class midori key F5
  sleep 1m #sleep the code for 1 minute or "sleep 60" can be used as well
done

0

There are 0 best solutions below