LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-28-2008, 06:57 PM   #1
moagalbm
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Rep: Reputation: 0
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
 
Old 02-28-2008, 07:04 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
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.
 
Old 02-28-2008, 07:11 PM   #3
moagalbm
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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).
 
Old 02-28-2008, 08:01 PM   #4
sdct989
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
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.

Last edited by sdct989; 02-28-2008 at 08:02 PM.
 
Old 02-28-2008, 10:15 PM   #5
moagalbm
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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,
 
Old 02-29-2008, 04:22 AM   #6
Farzan Mufti
LQ Newbie
 
Registered: Feb 2007
Location: USA/Canada
Distribution: Red Hat, CentOS, Scientific, Fedora, Ubuntu, SUSE, SLES
Posts: 14

Rep: Reputation: 6
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.
 
Old 02-29-2008, 08:05 AM   #7
utoddl
LQ Newbie
 
Registered: Oct 2005
Location: Sanford, NC
Distribution: Fedora, Ubuntu
Posts: 3

Rep: Reputation: 1
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.
 
Old 02-29-2008, 06:16 PM   #8
moagalbm
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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.

Last edited by moagalbm; 02-29-2008 at 10:19 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job not working bittus Linux - Software 7 04-27-2009 08:39 PM
simple cron job: not working Robert0380 Linux - Software 3 06-24-2008 05:45 AM
Cron Job Not Working... ALInux Linux - Software 2 07-24-2007 05:15 AM
Cron job not quite working... simba_cubs Linux - General 10 11-08-2006 07:27 AM
GPG cron job not working michredhat Linux - Software 1 12-07-2004 11:27 PM


All times are GMT -5. The time now is 06:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration