Shell如下:
#!/bin/bash #defined export JAVA_HOME=/root/.jenkins/tools/hudson.model.JDK/jdk8 NUM="$1" TOMCAT_HOME="/opt/soft/tomcat_cluster/tomcat_$NUM" if [ $NUM = 1 ] then TOMCAT_PORT=8090 fi if [ $NUM = 2 ] then TOMCAT_PORT=8100 fi if [ $NUM = 3 ] then TOMCAT_PORT=8110 fi if [ $NUM = 0 ] then TOMCAT_PORT=8060 fi #shutdown tomcat #"$TOMCAT_HOME"/bin/shutdown.sh #echo "tomcat shutdown" #check tomcat process tomcat_pid=`/usr/sbin/lsof -n -P -t -i :$TOMCAT_PORT` echo "current :" $tomcat_pid while [ -n "$tomcat_pid" ] do sleep 5 tomcat_pid=`/usr/sbin/lsof -n -P -t -i :$TOMCAT_PORT` echo "scan tomcat pid :" $tomcat_pid if [ -n "$tomcat_pid" ]; then echo "kill tomcat :" $tomcat_pid kill -9 $tomcat_pid fi done #start tomcat cd "$TOMCAT_HOME" ./bin/startup.sh 复制代码