I build a cronjob to download a new picture from a source every ten minutes and set it as wallpaper using feh. The file is downloaded but the wallpaper doesn't change. Where is the problem? crontab -e executes commands as the user so it should be as i would run the line - which works btw.

here is the script


file="space-"$(date +%x_%H:%M:%S)

#save it 
wget http://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/full_disk_ahi_true_color.jpg -O /home/tim/Bilder/Wallpaper/$file -o /dev/null

#set background
feh --bg-max /home/tim/Bilder/Wallpaper/$file

Here's crontab -e for the user which background should be changed (aka me)

*/10 * * * * /bin/sh /home/tim/Dokumente/Scripts/wallpaper.sh

In my syslog I found these lines

Jan 31 21:40:01 LinuxMint CRON[18209]: (tim) CMD (/bin/sh /home/tim/Dokumente/Scripts/wallpaper.sh)
Jan 31 21:40:11 LinuxMint CRON[18204]: (CRON) info (No MTA installed, discarding output) 

Unfortunately, it's not emphasized enough that the environment processes started by cron get is very simple, it contains only the most vital variables and values. You can check it by running a shell script that contains only


set > /tmp/myset.txt

You will see that there is no DISPLAY variable set there that would be needed to run any X-based applications (and apart from rare exceptions, all we use is that kind).

You have to put something like

export DISPLAY=:0.0

into your script and to have better odds.


To complete Gombai's answer with instructions:

Run env | grep -i display and check the value of DISPLAY. It is probably :0.0, or :0.

Modify your crontab accordingly:

*/10 * * * * DISPLAY=:0 /bin/sh /home/tim/Dokumente/Scripts/wallpaper.sh
  • Your solution helped me a lot, finally I get my script running! Keep up the good work! Oct 12 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.