#!/bin/sh
checkPid(){
pid=$$
name=`basename $0`
echo $pid $name
if [ -f ./d.pid ]; then
lastPid=`cat ./d.pid |awk '{print $1}'`
echo $lastPid
x=`ps -ef|grep $name |grep -v grep |grep -v awk |awk -v p=$lastPid -v n=$name '{if($2~p && $NF~n){print $0}}' |wc
-l`
echo $x
if [ "$x" -eq "1" ]; then
exit
fi
fi
echo $pid `date` > d.pid
return 0
}
checkPid
checkPid(){
pid=$$
name=`basename $0`
echo $pid $name
if [ -f ./d.pid ]; then
lastPid=`cat ./d.pid |awk '{print $1}'`
echo $lastPid
x=`ps -ef|grep $name |grep -v grep |grep -v awk |awk -v p=$lastPid -v n=$name '{if($2~p && $NF~n){print $0}}' |wc
-l`
echo $x
if [ "$x" -eq "1" ]; then
exit
fi
fi
echo $pid `date` > d.pid
return 0
}
checkPid