tomcat自启动脚本

#!/bin/sh
#chkconfig: 2345 80 90
#description: tomcat

JAVA_HOME=/usr/java/jdk1.7.0_79
PATH=$PATH:/usr/java/jdk1.7.0_79/bin

TOMCAT_CLI=/home/tomcat7/bin/startup.sh
PIDPORT=`echo $(ps -ef |grep tomcat |grep -w 'tomcat7'|grep -v 'grep'|awk '{print $2}')`

case "$1" in
start)
if [ -n "$PIDPORT" ]
then
echo "$PIDPORT tomcat exists, process is already running."
else
echo "Starting tomcat server..."
$TOMCAT_CLI
echo "$(ps -ef |grep tomcat |grep -w 'tomcat7'|grep -v 'grep'|awk '{print $2}') is running..."
fi
;;
stop)
if [ ! -n "$PIDPORT" ]
then
echo "tomcat process is not running."
else
echo "Stopping tomcat..."
kill -9 $PIDPORT
sleep 2
if [ `ps -ef |grep tomcat |grep -w 'tomcat7'|grep -v 'grep'|wc -l` -eq 0 ]
then
echo "tomcat is stop..."
fi
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/tomcat {start|stop|restart|force-reload}" >&2
exit 1
esac

 

posted @ 2017-07-11 16:33  鸾舞春秋  阅读(309)  评论(0编辑  收藏  举报