批量启动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