sorry.. I missed one thing..
This is the right condition line:
ps -ef | grep $0 | grep -v $$ | grep -v grep | grep $0

-----Original Message-----
From: Jayakumar Rajagopal 
Sent: Thursday, April 01, 2004 5:30 PM
To: [EMAIL PROTECTED]; Perl List
Subject: RE: Check if another script running


I think your question is more related to unix than perl.
Try something like this in shell script :
program=$0
while ps -ef | grep $0 | grep -v grep | grep $$
do 
   sleep 10
done

or in perl

$program=$0;
while (  `ps -ef | grep $0 | grep -v grep | grep $$` ) {
         sleep 10 ;
        }

** I did not check the stuff... ***

Jay

-----Original Message-----
From: Mike Blezien [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 3:47 PM
To: Perl List
Subject: Check if another script running


Hello,

I need to setup a cronjob to run a script every 2hrs, but if another particular
script(executed via a standard web form), on the same machine, is being
executed, I want the cron script "wait" or "sleep();" till the other script is
finished.

Is this possible to do and how is the best way to accomplish this task. :)

TIA
-- 
Mike<mickalo>Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Quality Web Hosting
http://www.justlightening.net
MSN: [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to