#!/bin/bash
# Tomcat init script for Linux
# chkconfig: 2345 96 14
# discription: The Apache Tomcat Server/JSP container
JAVA_HOME=/usr/local/jdk1.8.0_171/
CATALINA_HOME=/usr/local/tomcat
start_tomcat=$CATALINA_HOME/bin/startup.sh #tomcat启动文件
stop_tomcat=$CATALINA_HOME/bin/shutdown.sh #tomcat关闭文件
start() {
echo -n "Starting tomcat: "
${start_tomcat}
echo "tomcat start ok."
}
stop() {
echo -n "Shutting down tomcat: "
${stop_tomcat}
echo "tomcat stop ok."
}
#See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 5
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
其中2345是默认启动级别,级别有0-6共7个级别。是指tomcat在2345级别自动启动。
96启动优先级,14停止优先级,优先级范围是0-100,数字越大,优先级越低。
JAVA_HOME=/usr/local/jdk1.8.0_171/ 指定JAVA目录
CATALINA_HOME=/usr/local/tomcat #指定tomcat路径
$CATALINA_HOME/bin/catalina.sh $* #指定tomcat运行脚本