Page 1 of 1

Crontab job not working

Posted: Tue Nov 12, 2013 1:10 am
by TurboMax
Hiya I'm hoping you can help a noob out.

I'm trying to run a cron job that will run a slideshow with Qiv. The cron job will stop and start qiv every night to run with the latest pictures added to the folder. Here is the text of my crontab:

59 1 * * * kill all qiv
* 2 * * * sudo qiv -fs /home/pi/Desktop/slideshow/*.jpg -m -t -d 5 -i

I've ran the commands at the command prompt and they work just fine. But for some reason I can't get them to run from crontab. I've tried adding a command at the end to echo some words to a file, and that works, so I know the crontab job is running when I tell it to.

What am I doing wrong?

Re: Crontab job not working

Posted: Tue Nov 12, 2013 9:03 am
by DougieLawson
You can't run a graphic program from cron without some additions. There won't be a DISPLAY environment variable set when it runs.

Code: Select all

59 1 * * * sudo killall qiv
* 2 * * * DISPLAY=:1 sudo /usr/binqiv -fs /home/pi/Desktop/slideshow/*.jpg -m -t -d 5 -i
Also it's normally better to put commands that need to be run as root in root's crontab (rather than your unprivileged user's crontab with sudo). Edit that with sudo crontab -e