重启Tomcat的shell脚本

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

#!/bin/sh
#Author : gudaihui
#Desc : restart tomcat
#Time : 2013-06-05

tomcatpath="/usr/local/tomcat-6.0.18/"
tomcatname="tomcat-6.0.18"
tomcatsh="tomcat6.sh"


if [ $# -ne 1 ]; then
        ps -ef | grep java | grep ${tomcatpath};
        pid=$(ps -ef | grep java | grep ${tomcatpath} | awk '{print $2}')
else
        pid=$1
fi

echo -e "Before start ${tomcatpath}, should kill the same run, kill pid ${pid} (yes/no)? \c"
read Confirm

case $Confirm in
y|Y|yes|Yes)
        rm -rf ${tomcatpath}work/Catalina/localhost/*
        kill -9 $pid
        rm -f ${tomcatpath}${tomcatname}.pid
        sleep 1
        /etc/init.d/${tomcatsh} start; tail -f ${tomcatpath}logs/catalina.out
        ;;
*)
        echo "Restart ${tomcatpath} is Canneled"
        ;;
esac