Re: check if another process on my perl program is running
From: Dave Sisk (dsisk_at_nc.rr.com.0nospam0)
Date: 03/05/04
- Next message: Hal Vaughan: "Not getting cookies in LWP"
- Previous message: Dave Sisk: "Right regex to match -- comments or blank line?"
- In reply to: Erik: "Re: check if another process on my perl program is running"
- Next in thread: Pierre-Yves: "Re: check if another process on my perl program is running"
- Reply: Pierre-Yves: "Re: check if another process on my perl program is running"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 05 Mar 2004 05:04:52 GMT
You can probably do a backtick ps -ef | grep your_script_name or something
similar. For instance, if you your script is "onlyone.pl", then you should
be able to do something like this in the script:
$rv = `ps -ef | grep onlyone.pl`;
if ($rv == onlyone.pl) die;
"Erik" <elremovethis@thistoolinux.nu> wrote in message
news:piM1c.51209$mU6.208771@newsb.telia.net...
> Pierre-Yves wrote:
> >
> >
> > Thanks Erik!
> > I'm working with a flag file now and I would like to get rid of this
because
> > as you said when the script exits on an unexpected error, then the
> > intervention of an operator is required to delete the flag file... It
> > doesn't happen very often but during the last 3 weeks it happened 2
times
> > and it's blocking our business...
> > That's why I thought about something like checking the running
processes...
>
> Aha, I see!
> In an hack I did some time ago I "solved" the problem with the flagfile
> with an even dirtier hack...
> I made a sub called "SafeExit" or something, in that sub I closed and
> deleted my flagfile and finally made a "die".
>
> As I said, not very nice... But it worked...
> This program was a batchprogram so I could just (almost) ignore the fact
> that someone pressed ctrl-c or klicked the upper right corner.
>
> If you find any good solution, please post it. Maby I'll change that old
> hack to make it more clean. :-)
>
> ./Erik
>
- Next message: Hal Vaughan: "Not getting cookies in LWP"
- Previous message: Dave Sisk: "Right regex to match -- comments or blank line?"
- In reply to: Erik: "Re: check if another process on my perl program is running"
- Next in thread: Pierre-Yves: "Re: check if another process on my perl program is running"
- Reply: Pierre-Yves: "Re: check if another process on my perl program is running"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|