cron job is not working
I created the below script to pop-up an xterm window and when I add it to a corn job it is not working although it is working fine when I execute it manually.
Please look at this problem and let me know what is wrong. Thank you, #!/bin/sh /usr/bin/xterm -display lnx1c059:0.0 -fg white -bg DarkSlateBlue -fn 9x15 -T 'BCC Solaris Servers Regression TEST 3' -geometry 50x50+80+100 -n 'SUN_REGRESSION' -e /home/exp_3/operator/TMP_REG.lnx/TMP_REG/all3 & exit |
Well, it'd be nice to know what you mean by 'not working'. We need details eg error msgs etc.
Having said that, my first guess would be that since cron is designed to run detached ie no terminal, you're prob getting an email (prob in root) saying something like 'invalid cmd' or 'no terminal to connect to' etc. |
What I mean is that the cron job won't produce the pop-up window and for your information am running other commands in the same cron job and they are working fine exept for this popo-up window (xterm).
|
Are you running the cron job as the same user who started the X session that you expect the xterm window to pop up in?
If not, (and maybe even if so, I've never actually tried to do what you're doing) then one of the problems is most likely that the script doesn't know what display to use when launching the xterm session. You can see this in action if you open a terminal, su to a different user than the one who started X, and then run the same command you are trying to run now. From there you could either try using the same user that you created the X session with to run the cron job, or you could set the DISPLAY environment variable. For more information on that see: http://www.linuxquestions.org/questi...isplay-365193/ If that doesn't help or you already knew all that it would probably help you to redirect stdout and stderr to a file to give you a better clue as to what is happening. |
I did the redirection and this is what I got:
[operator@lnx1c059 /tmp]$ more sdderr Xlib: connection to "lnx1c059:0.0" refused by server Xlib: No protocol specified xterm Xt error: Can't open display: lnx1c059:0.0 xterm: DISPLAY is not set Remember that when I run it manually it works fine. Can you please help me out to resolve this display problem. Thanks, |
Try to do this in cron
* * * * * echo "Hello" Does this work? Whenever I tried this, it would send me an email. I don't think cron supports screen displays. If it does, then may be by using some special technique. |
The following works for me in my crontab:
* * * * * DISPLAY=:0.0 /usr/bin/xterm -fg white -bg DarkSlateBlue -fn 9x15 -T 'BCC Solaris Servers Regression TEST 3' (This runs every minute, and is rather annoying!) The relevant part here is to set the DISPLAY environment variable before the xterm command. It looks like you are calling a script instead of starting your xterm directly from cron. That should work fine, too. I think what's confusing you is that your "-display lnx1c059:0.0" is a little too complicated. That's probably being set up by your graphical login manager. Try "-display :0.0", or put "DISPLAY=:0.0" before your script invocation in your crontab entry, like I did above. Good Luck. |
I have tested the last solution and it works fine.
I would like to thank you all and special thanks goes to utoddl I really appreciate your help. |
All times are GMT -5. The time now is 08:18 PM. |