I have a script that looks for itself too. If i wanted it to not run if an instance of
itself was
already running i would do something like this (inside the script)
ps -ef |grep $0 |grep -v grep && exit 1
That prints no error message, is not friendly, etc, but it does it.
Cheers,
j
--- Karl Cunningham <[EMAIL PROTECTED]> wrote:
> 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?
>
>
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/