批量启动tomcat脚本,配置NUM可控制启动数量
1 #!/bin/bash 2 3 #identifier 4 CLUSTER_HOME=/opt/cluster-tomcat 5 TNAME=tomcat-8.5.32-0 6 TPORT=808 7 NUM=2 8 MUTE=" >> /dev/null 2>&1" 9 COPYRIGHT="~~~~~~~~~~~Powered by GuangSoft"10 11 #script12 for i in `seq 1 $NUM`;13 do14 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&115 if [ $? -ne 0 ]16 then17 echo -e "\nstarting ${TNAME}${i}. $COPYRIGHT\n"18 STARTSCRIPT="$CLUSTER_HOME/$TNAME${i}/bin/startup.sh $MUTE"19 eval $STARTSCRIPT20 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&121 if [ $? -ne 0 ]22 then23 echo -e "\n${TNAME}${i} has started successful! $COPYRIGHT\n"24 else 25 echo -e "\n${TNAME}${i} start failed! $COPYRIGHT\n"26 fi27 else 28 echo -e "\n${TNAME}${i} is already started! $COPYRIGHT\n"29 fi30 done
批量关闭tomcat脚本,配置NUM可控制关闭数量
1 #!/bin/bash 2 3 #identifier 4 CLUSTER_HOME=/opt/cluster-tomcat 5 TNAME=tomcat-8.5.32-0 6 TPORT=808 7 NUM=3 8 MUTE=" >> /dev/null 2>&1" 9 COPYRIGHT="~~~~~~~~~~~Powered by GuangSoft"10 11 #script12 for i in `seq 1 $NUM`;13 do14 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&115 if [ $? -ne 0 ]16 then17 echo -e "\n${TNAME}${i} is already stopped! $COPYRIGHT\n"18 else 19 echo -e "\nstopping ${TNAME}${i}. $COPYRIGHT\n"20 STOPSCRIPT="$CLUSTER_HOME/$TNAME${i}/bin/shutdown.sh $MUTE"21 eval $STOPSCRIPT22 netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&123 if [ $? -ne 0 ]24 then25 echo -e "\n${TNAME}${i} stop failed! $COPYRIGHT\n"26 else 27 echo -e "\n${TNAME}${i} has stopped successful! $COPYRIGHT\n"28 fi29 fi30 done