[lvhongmin@AY1401201736089361adZ start_svr]$ cat startall_svr.sh
#!/bin/bash
errpath[0]=‘‘
errnum=0
runnum=0
curr_path=`pwd`
#启动各进程的脚本完整路径及名字
array[${#array[*]}]=/home/lvhongmin/bin/bin.gatemaster/restart_proxy
slp[${#slp[*]}]=5
array[${#array[*]}]=/home/lvhongmin/bin/bin.connect/restart_proxy
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.ss.hall/restart_proxy
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.cornucopia/go.lhm.cornucopia
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.ddz.match/go.lhm.ddz.match
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.ddz.pt/go.lhm.ddz.pt
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.horse/go.lhm.horse
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.hsz.pt/go.lhm.hsz.pt
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.jpwl.pt/go.lhm.jpwl.pt
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.lzddz.pt/go.lhm.lzddz.pt
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.pklottery/go.lhm.pklottery
slp[${#slp[*]}]=2
array[${#array[*]}]=/home/lvhongmin/bin/bin.six/go.lhm.six
slp[${#slp[*]}]=1
array[${#array[*]}]=/home/lvhongmin/bin/bin.record.lhm/go.lhm.record.svr
slp[${#slp[*]}]=1
#declare -a array
len=${#array[*]}
echo "server num=" $len
for((i=0; i<$len;i++ ))
do
# echo ${array[$i]}
exen=${array[$i]}
slpnum=${slp[$i]}
if [ -f $exen ]; then
echo ${exen} ‘ >> ‘ $slpnum
#get the path
fpath=${exen%/*}
echo $fpath
# go to the path
cd $fpath
${exen}
#use proper sleep time
sleep $slpnum
runnum=`expr $runnum + 1`
else
echo ‘ --‘ $exen
errpathn[$unnum]=$exen
errnum=`expr $errnum + 1`
fi
done
cd $curr_pathstartallserver,布布扣,bubuko.com
startallserver
原文:http://blog.csdn.net/wusthongmin/article/details/27494753