Shell批量啟動、關閉tomcat


批量啟動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 #script 12 for i in `seq 1 $NUM`; 13 do
14     netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
15     if [ $? -ne 0 ] 16     then
17         echo -e "\nstarting ${TNAME}${i}. $COPYRIGHT\n"
18         STARTSCRIPT="$CLUSTER_HOME/$TNAME${i}/bin/startup.sh $MUTE"
19  eval $STARTSCRIPT 20         netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
21         if [ $? -ne 0 ] 22         then
23         echo -e "\n${TNAME}${i} has started successful! $COPYRIGHT\n"
24         else 
25         echo -e "\n${TNAME}${i} start failed! $COPYRIGHT\n"
26         fi
27     else 
28         echo -e "\n${TNAME}${i} is already started! $COPYRIGHT\n"
29     fi
30 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 #script 12 for i in `seq 1 $NUM`; 13 do
14     netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
15     if [ $? -ne 0 ] 16     then
17         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 $STOPSCRIPT 22         netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
23         if [ $? -ne 0 ] 24         then
25         echo -e "\n${TNAME}${i} stop failed! $COPYRIGHT\n"
26         else 
27         echo -e "\n${TNAME}${i} has stopped successful! $COPYRIGHT\n"
28         fi
29     fi
30 done

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM