Use cron to screen capture on Mac OS X

If you look at the end of the screencapture manpage, you see it says:

To capture screen content while logged in via ssh, you must launch
screencapture in the same mach bootstrap hierarchy as loginwindow:

PID=pid of loginwindow
sudo launchctl bsexec $PID screencapture [options]

So I think you could do somethig like this in your shell script that cron calls:

#/bin/sh
loginwindowpid=`ps axo pid,comm | grep '[l]oginwindow' | sed -n 's# *\([^ ]*\).*$#\1#p'`
sudo launchctl bsexec $loginwindowpid screencapture /somedir/screen.png

Of course, you'll need your userid set to not need a password for sudo.
That is you'd set in /etc/sudoers with the visudo command

youruserid     ALL=(ALL) NOPASSWD: ALL