1、tomcat启动脚本

#!/bin/sh
# description: 启动tomcat多实例.
. /etc/init.d/functions
RETVAL=$?
# tomcat实例目录
export CATALINA_BASE="$PWD"
# tomcat安装目录
export CATALINA_HOME="/var/opt/tomcat"
# 可选
export JVM_OPTIONS="-Xms128m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m"
case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];then
echo "Start Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];then
echo "Stop Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL

2、tomcat 关闭服务脚本

#!bin/bash
#杀掉tomcat进程

package=${*}
dir='/var/opt/tomcat'
pid=ps -ef | grep "${dir}/${package}"|grep -v 'grep' | awk '{print $2}'
if [ ! -n "$pid" ];then
echo -e "\033[31m service not alive \033[0m"
else
echo -e "\033[32m The tomcat stop process $pid \033[0m"
/bin/kill -9 $pid
sleep 2
echo -e "\033[31m Tomcat is status stop \033[0m"
fi