I'm writing a shell script that will have problems if another instance of 
itself is running, and I'd like to be able to trap that the user has 
started multiple instances.  I've tried

cnt=`ps ax | grep -c xyz`

where xyz is the name of the script.  It returns 3 when there is only one 
instance running.  I think I understand why it's 3 (one for the script 
itself, one for it running ps and one for it running grep?).  Will this 
always work?  Is there a better way?


Reply via email to