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