Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I really would like to be able to use crontab to update something every 3hrs, BUT crontab won't run my script with enough priveleges to run a GUI.

Clarification: I have a complicated script that generates a picture (based on the current available web content from a couple of servers) every 3hrs - I want to have it display what it is that it's doing so I know whether it failed or not.

I've tried: 1. Adding a file to /etc/cron.d/myscript for cron to run 2. variations of xdg-open, gnome-terminal, mrxvt -e, env DISPLAY=:0.0, root /usr/local/bin/myscript 3. Editing my user cron -- crontab -u username -e

Myscript is a complicated little beastie that downloads a picture (which is updated every half hr) then downloads a different websites webpage as index.html - sed's it, finds the particular image it needs (based on today's date & time) then crops and transforms it, with imagemagick.

share|improve this question
If you are talking about user privileges, you can create crontab entries for root user to get the needed privileges. – Khaled Jan 31 '11 at 7:33
Displaying stuff on a different user's display is highly non-trivial, even if you are root. What is this "thing" you want to run every 3 hours, and what do you want to show to the user? There are several notification services on Linux (copycats of "Growl" for Mac) which may provide what you need. – unixtippse Jan 31 '11 at 7:51
Please provide more details of exactly what you are trying to do, what you have attempted, and where it's failed. – Phil Hollenback Jan 31 '11 at 8:14
man xauth
man xhost

You can try xhost local: as the beginning.

share|improve this answer
Thanks for the suggestion! I've tried editing with crontab -e --- 42 23 31 1 * xhost local: /usr/local/sbin/ - but it didn't even run in the background. – palbakulich Jan 31 '11 at 10:46
You need to run "xhost local:" once per X server session. It's not a prefix for other commands, it just allows to connect to X server from local connections. – poige Jan 31 '11 at 12:08
So, to clarify, it does or doesn't go in the crontab entry? - Do I put this command into my script instead? – palbakulich Jan 31 '11 at 17:45
man, why don't you read man? :) Here it goes: «… The initial access control list for display number n may be set by the file /etc/Xn.hosts, where n is the display number of the server. See Xserver(1) for details. …» – poige Jan 31 '11 at 18:00

If you want to open a window on the user's desktop, you need to export the X11 authentication info from your user context and provide it to your root context.

As the user, export the xauth info:

$ xauth extract /home/foo/xauth-foo $DISPLAY
$ echo $DISPLAY

Then, as root, import it and start your X client:

# xauth merge /home/foo/xauth-foo
# export DISPLAY=:0.0
# xclock

This is untested from my notes. I haven't had a use case for this in at least 5 years.

share|improve this answer
is the xauth-foo file likely to be .Xdefaults? I'm not sure which file to perform xauth extract. Is $DISPLAY the only variable we are extracting with xauth? – palbakulich Jan 31 '11 at 17:34
No, xauth-foo is xauth-foo. Call it what you like. It's especially unrelated to .Xdefaults. It's somewhat related to .Xauthority, though, but still different from it, because it's a container for transferring xauth info into another context. $DISPLAY is the display from which you want to export xauth info. – unixtippse Jan 31 '11 at 21:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.