I want to take a screenshot every five minutes with 'scrot'. To do this over a SSH connection, I can either run
ssh -X user@server
while true; do scrot -z; sleep 300; done
OR (after manually check of folder name in /var/run/gdm/auth-for-XXX-YYY/database)
ssh user@server
export DISPLAY=:0
export XAUTHORITY=/var/run/gdm/auth-for-user-wUM1sV/database
while true; do scrot -z; sleep 300; done
But if I want to do this as a cron job, I will automatically need to map the environment variable XAUTHORITY to the random folder in /var/run/gdm/. According to this post How do I create the .Xauthority file? this mapping is done automatically, but that is not the case for cron jobs I guess and apparently not for SSH sessions if X forwarding is not used.
Does anyone have a suggestion on how to create this cron job?