#!/bin/bash
tomcat_home=/opt/usr/local/tomcat-8.5.57
SHUTDOWN=$tomcat_home/bin/shutdown.sh
STARTTOMCAT=$tomcat_home/bin/startup.sh
echo $2 $1 $tomcat_home
#echo $pidlis1t1
case $1 in
start)
echo "start $tomcat_home"
$STARTTOMCAT
tail -f $tomcat_home/logs/catalina.out
;;
stop)
echo "stop $tomcat_home"
$SHUTDOWN
pidlist=`ps -ef |grep tomcat |grep -v "grep"|awk ‘{print $2}‘`
kill -9 $pidlist
#删除日志文件,如果你不先删除可以不要下面一行
rm $tomcat_home/logs/* -rf
#删除tomcat的临时目录
rm $tomcat_home/work/* -rf
;;
restart)
echo "stop $tomcat_home"
$SHUTDOWN
pidlist=`ps -ef |grep tomcat |grep -v "grep"|awk ‘{print $2}‘`
kill -9 $pidlist
#删除日志文件,如果你不先删除可以不要下面一行
rm $tomcat_home/logs/* -rf
#删除tomcat的临时目录
rm $tomcat_home/work/* -rf
sleep 5
echo "start $tomcat_home"
$STARTTOMCAT
#看启动日志
tail -f $tomcat_home/logs/catalina.out
;;
logs)
cd /opt/usr/local/tomcat-8.5.57/logs
tail -f catalina.out
;;
esac