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.

ken:~$ crontab -u ken -l
* * * * * /home/ken/capture >> /home/ken/test.log 2>&1
* * * * * /home/ken/analyze
test.log was throwing this error:
import: unable to open X server `0:0'.
The key here was adding the exports $DISPLAY and $HOME:
export DISPLAY
export HOME
import -window "XP FXDD" -crop 16X28+1191+127 pic.jpg
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.