RE: Check if another script running

2004-04-02 Thread Jayakumar Rajagopal


-Original Message-
From: Mike Blezien [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 3:16 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
-- 
MikemickaloBlezien

Mike,
Are you sending this mail through a cronjob? You have been provided 3 different 
answers, but still you are sending the same question for 3rd or 4th time?
Jay

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




Re: Check if another script running

2004-04-02 Thread Mike Blezien
My appologize for the multiple emails... something went hay-wire with our mail 
server yesterday.. sending out multiple emails.

this question has been resolved,.. thanks to the list for the help :)

Mike

Jayakumar Rajagopal wrote:
-Original Message-
From: Mike Blezien [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 3:16 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


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



Check if another script running

2004-04-01 Thread Mike Blezien
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
--
MikemickaloBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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



Check if another script running

2004-04-01 Thread Mike Blezien
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
--
MikemickaloBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Check if another script running

2004-04-01 Thread Jayakumar Rajagopal
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
-- 
MikemickaloBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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




Re: Check if another script running

2004-04-01 Thread Mike Blezien
Hi Randy,

that was my original plan, but I though there maybe a better way others may use 
or suggest :)

Appreciate the feedback,

Mike

Randy W. Sims wrote:
On 4/1/2004 3:46 PM, Mike Blezien wrote:

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. :)


If you are able to modify both scripts, the traditional solution would 
be to have the cgi script create a lock file on startup, removing it 
when exiting. Then your other script can check for the presence of the 
lock file, if it exists, wait.

Regards,
Randy.


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



RE: Check if another script running

2004-04-01 Thread Jayakumar Rajagopal
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
-- 
MikemickaloBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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




Re: Check if another script running

2004-04-01 Thread Randy W. Sims
On 4/1/2004 3:46 PM, Mike Blezien wrote:

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. :)
If you are able to modify both scripts, the traditional solution would 
be to have the cgi script create a lock file on startup, removing it 
when exiting. Then your other script can check for the presence of the 
lock file, if it exists, wait.

Regards,
Randy.


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



Check if another script running

2004-04-01 Thread Mike Blezien
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
--
MikemickaloBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


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



Re: Check if another script running

2004-04-01 Thread Smoot Carl-Mitchell
On Thu, 01 Apr 2004 16:34:11 -0600
Mike Blezien [EMAIL PROTECTED] wrote:

 that was my original plan, but I though there maybe a better way
 others may use or suggest :)
 
 Appreciate the feedback,

If you are running this on a Unix/Linux system check out perldoc -f
flock. It enables advisory file locking. It avoids the complexity of
doing file locking by creating sentinel files using the standard Unix
atomic open semantics.  There are some serious race condition problems
with that approach.

The information in the perl manual for flock contains an example mailbox
locking routine which explains how to use flock to grant exclusive
access to a file.

-- 
Smoot Carl-Mitchell
Systems/Network Architect
email: [EMAIL PROTECTED]
cell: +1 602 421 9005
home: +1 480 922 7313

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