[lvhongmin@AY1401201736089361adZ start_svr]$ cat killall_svr.sh
#!/bin/bash
unrun[0]=‘‘
unnum=0
runnum=0
#进程的名字
array[${#array[*]}]=paiyouQuan.svr
array[${#array[*]}]=jjm.cornucopia.svr
array[${#array[*]}]=ddz.match.svr
array[${#array[*]}]=ddz.pt.svr
array[${#array[*]}]=jjm.horse.svr
array[${#array[*]}]=ddz.hsz.pt.svr
array[${#array[*]}]=ddz.jpwl.pt.svr
array[${#array[*]}]=ddz.laizi.pt.svr
array[${#array[*]}]=jjm.pklottery.svr
array[${#array[*]}]=jjm.six.svr
array[${#array[*]}]=jjm.record.svr
array[${#array[*]}]=xxddz.laizihall.exe
array[${#array[*]}]=lhm.connect.svr
array[${#array[*]}]=lhm.gatemaster.svr
#declare -a array
len=${#array[*]}
echo "server num=" $len
for((i=0; i<$len;i++ ))
do
# echo ${array[$i]}
exen=${array[$i]}
INFO=`ps aufx | grep "${exen}$" | grep -v "grep" `
if [ "$INFO" ]; then
echo ${exen} ‘ **‘
killall -9 -q ${exen}
runnum=`expr $runnum + 1`
sleep 2
else
echo ‘ --‘ $exen
unrun[$unnum]=$exen
unnum=`expr $unnum + 1`
fi
done
if [ $unnum -gt 0 ] ; then
echo ‘‘
echo "unrunning server num = " $unnum
for((i=0;i<$unnum; i++))
do
echo ${unrun[$i]}
done
else
echo ‘‘
fi
echo ‘‘
echo $runnum ‘ is killed‘killallserver,布布扣,bubuko.com
killallserver
原文:http://blog.csdn.net/wusthongmin/article/details/27495509