I am trying to find number of runs of a script but its always 2 even though only one running.
sh 11.sh
1
11.sh already running,exiting..
here is code.
ps -ef | grep -v grep | grep -c "$0"
if [[ `ps -ef | grep -v grep | grep -c "$0"` -gt "1" ]]; then
`echo " $0 already running,exiting.."`
fi
pgrep
instead.