What is wrong with this list...This is my third attempt, in as many days, to post this
message.
Here it is again:
Ok, i know this has been solved, but i would like to add a few more
unique solutions. I did not
think of the first one, a friend of mine did:
1. Have the process write it's pid to a file, and before it does that
it checks to see if another
has already done that. If so, it verifies that the other pid is
actually currently active (ie.
it's PID exists). This sounds easy enough to implement.
2. And finally, something that seems to be overlooked (and this may be
the easiest, most bestest
way to do it):
Take a look at how all the services do it. They source a function
called "status" out of
/etc/rc.d/init.d/functions and use that. This one seems fairly
comprehensive. You can also look at
how they deal with "start"ing a service or "stop"ping it (which
involves a quick check). And while
you're at it, you could just set it up as a service, if you wanted to
(be sure to steal all the
relevant start|stop|reload|status|etc cases in the various service
scripts.
Ok we've (over?)done that topic. Next.... :-)
j
--- Karl Cunningham <[EMAIL PROTECTED]> wrote:
> To John, Dan, Rusty -- Thanks very much for your help. In this case,
> directing output to an interim file gave different results than
piping it
> all in one line, but trying it led me to the answer. I believe the
> ambiguity is in which of the processes involved in the pipes have
been
> started in time for ps to catch them.
>
> The following seems to work reliably:
>
> temp=`ps -ef`
> if [ `echo $temp | grep -c $0` -gt 1 ] ; then
> echo "another is running"
> else
> echo "all alone"
> fi
>
>
> thanks again
> karl
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/