Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cronjob defunct? 1

Status
Not open for further replies.

oceandeep

IS-IT--Management
Jul 6, 2000
69
GR
Hi,

I setup a cronjob recently on RH AS3 to check if my application is running every minute. But whenever I issue ps -e, I can see something like:
16898 ? 00:00:00 checkmon <defunct>

my crontab file is as below:
* * * * * /servicemon/checkmon

and checkmon is just a simple script:
##########################
#!/bin/sh

isRunning=`ps -e | grep -v grep | grep servicemon`
if [ "X${isRunning}" = "X" ]; then
cd /servicemon
./servicemon & > /dev/null
fi
exit 0
##########################

Would that be a problem or just an expected behaviour in linux? But I don't have this with Solaris.

And another question, how can I run cron job for every few seconds?

Thanks!
- Jiang -
 
Does checkmon need any variables that cron won't have as part of it's environment, $PATH for example? If so, you need to include these at the start of your script.

As far as I know, cron isn't designed for use in fractions of a minute. However, if you set up your monitoring script so that it kicks off, then sleeps for n seconds before calling itself again, you can approximate such behaviour.
 
[tt]./servicemon & > /dev/null [/tt]

Does & work before a redirection? Maybe it does, but I usually make it the very last thing on the line.

Also you might want to redirect standard error too:

[tt]./servicemon > /dev/null 2>&1 &[/tt]

Annihilannic.
 
Thanks Annihilannic and KenCunningham! Yes I put the "&" at the wrong place. The cronjob is now working fine after I move "&" to the end of the line.
 
Good spot Annihilanic!

All I ask of you is make my wildest dreams come true
 
I am trying to set up a crontab to download a build from a website using proz

Error: "Error opening terminal: unknown."

crontab entry:

54 14 * * * proz --no-getch -t=0 -k=20 > /var/log/cronrun 2>&1 &

This command works on command line, could some one help please
 
Hi,

As KenCunningham says above, try to replace proz with /full/path/to/proz

Ali
 
Hi,

I am not familiar with proz, and so I can only guess here.
But it seems to be the common problem that a cron job hasn't got all the necessary environment variables.
Let me, too, quote Ken:
Does <whatever> need any variables that cron won't have as part of it's environment, $PATH for example?
Another example is $TERM.
It may seem strange that a background job might need $TERM at all, but I remember having seen something like this.

hope this helps
 
Hi,

proz is a linux download accelerator

I did try setting up the $TERM=xterm as an environment variable. But that too doesn't work.

Do we need to restart the process after the changes are made to the crontab file.
 
With $TERM=xterm, which error message do you get? Still the same?
And how did you set $TERM? In your crontab file? Or did you create a script that first sets $TERM and then calls proz? (I would do the latter, by the way)
Usually you don't need to restart anything; just wait until your program is called again.

And what do you mean by 'changes are made to the crontab file' ?
I suppose you do know that you should not just edit the files in /var/spool/cron/tabs (or wherever they are in your system) ?
 
I do get the same error "Error opening terminal: unknown."

I tried setting the TERM in the script, but still get the same error. I didn't make any changes in the cron/tabs files.

 
hmm ...
So I am afraid I can't be helpful...
Any proz gurus out there?

One last idea:
You already told us that it works from command line;
plaese could you try again, two times, in background and in foreground, i.e. with and without & at the end of the line.
If there is a difference, this could give a hint.

regards
 
Hello,

I wasn't here yesterday, and as in the meantime nobody else came up with a solution, let me continue guessing now.

Now it seems your problem isn't with cron at all, but with background. I suppose as soon as you found out how to run it in background, it will run in cron as well.

In the cron command you have shown on 14 Nov 06 1:52, you have a & at the end of your command line. That at least seems needless; try without it.
I am quite sure that this won't help, but might be worth a try.

And then if you can't find anything helpful in your manuals, you might want to start a new thread whith a title like 'Sending proz to background', to attract the attention of proz gurus.

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top