Re: check if another process on my perl program is running
From: Pierre-Yves (pyu-at-belbone.be)
Date: 03/05/04
- Next message: Thorsten Gottschalk: "awk's NF in Perl"
- Previous message: Bob Dubery: "Imposing a timeout on the <> operator - is this possible?"
- In reply to: Dave Sisk: "Re: check if another process on my perl program is running"
- Next in thread: Jim Gibson: "Re: check if another process on my perl program is running"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 5 Mar 2004 09:48:58 +0100
"Dave Sisk" <dsisk@nc.rr.com.0nospam0> wrote in message
news:UTT1c.45563$%d3.4130628@twister.southeast.rr.com...
> 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
> >
>
Yep that's a good idea, doing a system call to "ps -e"
but i should rather count and see if there is more than 1 process otherwhise
my program will alwats die since it will always find its own process ;-)
thanks I'll try this !
- Next message: Thorsten Gottschalk: "awk's NF in Perl"
- Previous message: Bob Dubery: "Imposing a timeout on the <> operator - is this possible?"
- In reply to: Dave Sisk: "Re: check if another process on my perl program is running"
- Next in thread: Jim Gibson: "Re: check if another process on my perl program is running"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|