Operating System - HP-UX
1833871 Members
1656 Online
110063 Solutions
New Discussion

about a x window program executing

 
miaoxucheng
Advisor

about a x window program executing

hi ,expert !
I want to run an X window progran through CRON mechnism ,but I found there are some questions .who can tell me how I should to set the environments variables to run an X window program through CRON mechnism ?
5 REPLIES 5
Michael Tully
Honored Contributor

Re: about a x window program executing

I stand corrected if I'm wrong, but
doesn't an X program need a valid
display on which to run?

export DISPLAY=IP:0.0

if so you would need some from of tty in
which to do this. crons do not run on a
tty they run in the background.
Anyone for a Mutiny ?
H.Merijn Brand (procura
Honored Contributor

Re: about a x window program executing

most X-programs also support that through the -display option (GNU utils also through the --display= option)

xterm -bg gray90 -fg gray10 -display 127.0.0.1:0 &
Enjoy, Have FUN! H.Merijn
support_5
Super Advisor

Re: about a x window program executing

Hi,

There are a few ways:
In the command field of your crontab file, put:
export DISPLAY=:0 ;
or as already said, you can append on the command the -display :0 option which tells it to connect to the X server running on and located on window 0.

However, there are a few program which don't have this option. Eg. xhost doesn't have this option, but then, it's not really a X client program, but rather a manager of sorts of the X server.

Cheers.

- Andy Gray
Wodisch
Honored Contributor

Re: about a x window program executing

Hello,

to be safe, you'll need an "virtual fram buffer", like VNC, or like it is part of the recent X-server of HP-UX.
Then point your cron-job towards it:

# cron job:
export DISPLAY=5.4.3.2:1.0
your-x-client ...

where "5.4.3.2" is the IP-address of the frame-buffer, and "1" is the server-process number of it (since "0" usually is the local graphics screen).

HTH,
Wodisch
Bill Hassell
Honored Contributor

Re: about a x window program executing

cron, as you've seen, does not login like a 'normal' user, therefore has a minimum environment. So your cron script must source /etc/profile and .profile. However, some commands in the profiles are require a controlling terminal (like tabs and ttytype) so these must be skipped.

While this should be done anyway in /etc/profile, etc, it is easier to get your script started by adding all the environment settings to your script, including the DISPLAY variable.


Bill Hassell, sysadmin