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.

Code:
ken:~$ crontab -u ken -l
* * * * * /home/ken/capture >> /home/ken/test.log 2>&1
* * * * * /home/ken/analyze
test.log was throwing this error:
Code:
import: unable to open X server `0:0'.
The key here was adding the exports $DISPLAY and $HOME:
Code:
DISPLAY=:0
export DISPLAY
HOME=/home/ken
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.