词条信息

admin
超级管理员
版本创建者 发短消息   
简易百科旧版 >> shell脚本重启Tomcat服务器 >> 历史版本

最新历史版本 :shell脚本重启Tomcat服务器 返回词条



shell脚本重启Tomcat服务器,具体shell脚本如下:


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