A simple way to make this work, when on a local machine which already has a local user configured and able to access the X Server, is to do something like this with the Cron job line in
/etc/crontab:
Code:
* * * * * whatever-username DISPLAY=:0 XAUTHORITY=/home/whatever-username/.Xauthority whatever-xappl
I.e. the execution environment of a Cron job is rather bare as compared to your usual interactive or login environment, and it lacks those two envars,
DISPLAY and
XAUTHORITY.
I won't go into many of the particulars or nuances here, because there are quite a lot of them. A few installations have variable paths to their Xauthority data, for one thing. Another thing is that remote users, e.g. via ssh sessions, can't rely on the usual value for
DISPLAY.
You might need to write some procedures into your script rather than simply rely on envar definitions added to the commandline of a Cron job.
A lot of that information is available elsewhere on the internet, but suffice it to say that I hope at least a few runaday users, and maybe a few novice power users, might be helped by me mentioning this tidbit here. Cheers.