重启JBOSS & Tomcat

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash

#this shell will be used to restart Jboss & tomcat

runuser=`whoami`

workpath=$HOME/portal

echo "=============THE PROCESS JBOSS & TOMCAT WILL BE KILLED FIRST ================"

stop()
{
        echo "==============CHECKING THE PID FOR JBOSS AND TOMCAT ================"

        ps -ef|grep jboss|grep $runuser|grep -v grep|grep -v tomcat |awk ' { print $2 } ' |while read JPID
        do

        #if [ ! -z $JPID ];then
                echo "========JBOSS IS RUNING AND THE PID IS : $JPID ,WILL BE KILLED NOW ================="
                kill -9 $JPID
        #fi

        done
        TPID=`ps -ef|grep tomcat|grep $runuser|grep -v grep|awk ' { print $2 } ' `

        if [ ! -z $TPID ];then
                echo "========TOMCAT IS RUNING AND THE PID IS : $TPID ,WILL BE KILLED NOW ================"
                kill -9 $TPID
        fi
}

start()
{

        echo "============== JBOSS AND TOMCAT WILL BE RESTART NOW ==================="
        cd $workpath

        nohup ./1-jboss.sh &

        echo "STARTING JBOSS .... ...."
        sleep 5

        echo "STARTING TOMCAT ... ... "
        nohup ./2-tomcat.sh &

}

#===================================
# THE MAIN FUNCTION
#===================================

stop
sleep 1
start
exit 0