I was having some difficulty running screenshots thru cron and I've searched google and nothing had helped, so I figured I'd share my wisdom with the bunch.
I've created a shell script that takes a screenshot of a window every minute. I'm running this cron locally under my own user. I am able to run this script manually without a problem.
test.log was throwing this error:
ken:~$ crontab -u ken -l
* * * * * /home/ken/capture >> /home/ken/test.log 2>&1
* * * * * /home/ken/analyze
The key here was adding the exports $DISPLAY and $HOME:
import: unable to open X server `0:0'.
Once the exports were added to my script everything starting working fine. I ended up removing pcspkr (sudo modprobe -r pcspkr) because import beeps every time it takes a screenshot.
import -window "XP FXDD" -crop 16X28+1191+127 pic.jpg