首页 > 代码库 > tomcat重启脚本

tomcat重启脚本

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export JAVA_HOME=/opt/jdk/jdk1.7.0_79

export JAVA_BIN=/opt/jdk/jdk1.7.0_79/bin
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin

TomcatDir=/data/tomcat
TomcatCache=$TomcatDir/work/*
TomcatStart(){
rm -rf $TomcatCache
$TomcatDir/bin/startup.sh
tail -30f $TomcatDir/logs/catalina.out
}
TomcatID=$(ps -ef |grep tomcat |grep -w $TomcatDir|grep -v ‘grep‘|awk ‘{print $2}‘)
if [ $TomcatID ]
then
echo "tomcat路径为:"$TomcatDir",""tomcat进程id为:"$TomcatID",进程停止中"
kill -9 $TomcatID
TomcatStart
else
echo "没有该"$TocmatDir"进程,准备启动中...."
TomcatStart
fi

tomcat重启脚本