Bash: Continue script if only one instance is running.

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-03-27T17:02:27Z Indexed on 2010/03/27 17:03 UTC
Read the original article Hit count: 222

Filed under:
|

Hello, now this is embarrassing. I'm writing quick script and I can't figure out why this statement don't work.

if [ $(pidof -x test.sh | wc -w) -eq 1 ]; then echo Passed; fi

I also tried using back-ticks instead of $() but it still wouldn't work.

Can you see what is wrong with it? pidof -x test.sh | wc -w returns 1 if I run it inside of script, so I don't see any reason why basically if [ 1 -eq 1 ] wouldn't pass.

Thanks a lot!

© Stack Overflow or respective owner

Related posts about bash

Related posts about if-statement