[comp.unix.questions] process conflicts

jwm@SUN4.JHUAPL.EDU (James W. Meritt) (05/18/91)

Is there some way for a script to "tell" if another process with the same
name is running?  I'm trying:
............................................................
#! /bin/csh -f
set j=`ps -ax|grep $0| grep -v grep | grep csh`
echo "got string< $j >- $#j long"
if ($#j != "7") then
      echo have more processes named $0 running
else
      echo only this process named $0 is running
endif
..........................................................

Except that the results are inconsistent, especially if the script is run via
cron.

Opinions expressed are solely those of the author, and do not necessarily
represent those opinions of this or any other organization.  The facts,
however, simply are and do not "belong" to anyone.
    jwm@sun4.jhuapl.edu or jwm@aplcen.apl.jhu.edu or meritt%aplvm.BITNET