Help: use cron to run a GUI program



Hi,

I try to use cron to run a GUI program. I am halfway there and have some problems. The true nature of my problems actually have nothing to do with cron, but with X session.

My script "run_gui.sh" will export some environment variables including DISPLAY and XAUTHORITY and run a JAVA GUI program. To test if run.sh can be run by cron, I typed this command:

env -i /fs/path_to/run_gui.sh

(I find if the command above works, then cron will be able to run it; if not, cron of course cannot run it either.) This command sometimes work and sometimes don't. Within run_gui.sh:
export XAUTHORITY=...
export DISPLAY=host-machine-name:0.1

Every time when I log in, I need to use this two commands:
env | grep XAUTHORITY
env | grep DISPLAY
to find out the two variable values, then edit run_gui.sh:
export XAUTHORITY=the_value_i_found_by_"env | grep XAUTHORITY"
export DISPLAY=the_value_i_found_by_"env | grep DISPLAY"

After editing, then this command("env -i /fs/path_to/run_gui.sh") works.

If I logged into a different linux server, I have to change the two variable values in run_gui.sh based on the login. What can I do to make run_gui.sh always work, no need to change each time log in?

Another question I am unclear is, when the command works(same when cron run run_gui.sh work), the GUI is displayed on the screen. I thought when running cron--when it works, the GUI is not visible, because the machine is off. Am I wrong?

I know all these problems are due to my lack of knowledge about X session and XAUTHORITY stuff. I know nothing about them really. I could have to study two or three chapters of book. I am just curious if you could give me a jump start. Thank you very much.
.



Relevant Pages

  • Re: For me, it is impossible to use cron to run a GUI program when not logged in
    ... and logged out(These linux machines are shared desktops, ... Our IT support told me that my gui program have no place to ... since I was not logged in when the cron job ... Why is there a GUI if no user interaction is required? ...
    (comp.os.linux.misc)
  • Re: [opensuse] Re: Mac TimeMachine like backup for Linux?
    ... start a GUI from cron, and most backup programs aren't designed to be run manually. ... The GUI usually comes in when you want to restore things ... But cron might do the dailies... ...
    (SuSE)
  • Re: Cron Problem
    ... > |when you get ready to do something and a cron entry just happens to run. ... your xmms process is probably getting started but is not going ... Processes started by cron do not have a DISPLAY ... there is no need to use a GUI application like ...
    (alt.os.linux.suse)
  • Re: running rm cobol in a cron job
    ... which I am afraid you do not have from Cron. ... I don't know why it would need GUI to run a job overnight. ... terminal lke Konsol or RXvt. ...
    (comp.lang.cobol)
  • Re: [kde-linux] Cron emails dont respect my MAILTO
    ... indicate the mail was received from cron and delivered? ... It was sent from root to me at my local domain address. ... sendmail command must be installed without set-uid root file permissions ... mailing to one location and other commands mailing to about location (or using ...
    (KDE)