JBOSS & Tomcat再起動

linux環境でJBOSSとTomcatが再起動する。

#!/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

Comments are closed.