5

I've got a couple of scripts that I've had scheduled to run in cron for a while. About a week or so ago, they stopped running as far as the (very basic) logging showed, and also I noticed that my wallpaper wasn't being rotated any more.

josh@sirius:~$ crontab -l
# m h  dom mon dow   command
0 * * * * /bin/bash /home/josh/bin/rotate-wallpaper
*/30 * * * * /bin/bash /home/josh/bin/download-programmes
* * * * * echo "I ran" > /home/josh/cronstamp

Neither of the first two commands are run, but the ~/cronstamp file does get created and written to as expected.

3 Answers 3

4

Looks like your scripts are failing. I would suggest adding 2>&1 > /home/josh/cronlog at the end of your commands, this way you will be able to later inspect what went wrong

Example:

# m h  dom mon dow   command
0 * * * * /bin/bash /home/josh/bin/rotate-wallpaper 2>&1 > /home/josh/cronlog
*/30 * * * * /bin/bash /home/josh/bin/download-programmes 2>&1 > /home/josh/cronlog
2

Try reloading the cron jobs:

sudo service reload

available options are:

sudo service {start|stop|status|try-restart|restart|force-reload|reload|probe}
1
  • This doesn't seem to have made a difference.
    – dutchie
    Jan 30, 2012 at 10:26
1

Do your scripts depend on GUI elements (I guess so, since you talk about wallpapers)? Then I guess this won't work, as it misses out on some environment variables in Cron, opposed to running in a terminal window.

If you just need the $DISPLAY and you are not running multiple X-windows, set it like this in your script (on top):

DISPLAY=:0

Maybe more are missing. Try debugging further and log all stdout and stderr output from all commands in your scripts as @zakkak explains.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .