TurboMax
Posts: 1
Joined: Tue Nov 12, 2013 1:02 am

Crontab job not working

Tue Nov 12, 2013 1:10 am

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?

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Crontab job not working

Tue Nov 12, 2013 9:03 am

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
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Raspberry Pi OS”