[PLUG] Check program running...

Russ Gilman-Hunt (YAR) gilmanhunt at comcast.net
Wed Jan 24 18:24:16 UTC 2007


On Wed, 24 Jan 2007 10:10:39 -0800
"drew wymore" <drew.wymore at gmail.com> wrote:

> On 1/23/07, someone <plug_0 at robinson-west.com> wrote:
> >
> > On Tue, 2007-01-23 at 11:47 -0800, Russell Senior wrote:
> > > >>>>> "drew" == drew wymore <drew.wymore at gmail.com> writes:
> > >
> > > drew> just use pidof `process name`
> > >
> > > but not with backticks, which do something you don't want done
> > > here.
> > >
> > >
> >
> > [root at goose plug_0]# ps ax | grep perl
> > 24204 ?        S      0:05 /usr/bin/perl ./setdodoip.pl
> > 31462 pts/1    S+     0:00 grep perl
> > [root at goose plug_0]# /sbin/pidof setdodoip
> >
> > [root at goose plug_0]# /sbin/pidof ./setdodoip
> >
> > [root at goose plug_0]# /sbin/pidof /usr/bin/perl
> > 24204 4773 4772 4771 4770 4769 3625
> > [root at goose plug_0]# /sbin/pidof /usr/bin/perl setdodoip
> > 24204 4773 4772 4771 4770 4769 3625
> > [root at goose plug_0]# /sbin/pidof /usr/bin/perl ./setdodoip
> > 24204 4773 4772 4771 4770 4769 3625
> > [root at goose plug_0]#
> >
> > Well, I'm having a hard time getting the right one.
> >
> > The correct answer is 24204 in this case, but I'm having
> > a hard time getting that using pidof.
> >
> > Using the pidof command was a good suggestion though.
> 
> 
> Its looks like its returning all instances of /usr/bin/perl
> <whatever> can you invoke setdodoip without referencing perl first?
> You could always do something like
> 
> pidof /usr/bin/perl setdodoip |awk {'print $1'} which would give you
> the correct process id but it might change from time to time so its
> hard to say that it would always be correct.
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug

You have '/sbin/pidof ./setdodoip' above. Your script is setdodoip.pl.
I don't know if that makes much difference.

You might experiment with the -x flag, which is supposed to do
"scripts, too" (at least on my system, a quick man pidof should help).

Personally I'd play with drew's suggestion and toss in the script name
like "pidof perl | grep setdodoip\.pl | awk {'print $1'}"
-- 
Russ Gilman-Hunt
http://www.arghwebworks.com/
gilmanhunt at comcast.net



More information about the PLUG mailing list