启动、重启、停止tomcat脚本
脚本名称 xxx
# !/bin/bash
# description: starts the tomcat deamons
JAVA_HOME=/home/xxxx/jdk1.8.0_291
export JAVA_HOME
CATALINA_HOME=/home/xxxx/apache-tomcat-9.0.52
CATALINA_BASE=/home/xxxx/apache-tomcat-9.0.52/
export LANG=zh_CN.UTF-8
export CATALINA_HOME
case "$1" in
start)
echo "Starting Tomcat ..."
sleep 2
$CATALINA_HOME/bin/startup.sh
;;
stop)
echo "Stop Tomcat ..."
sleep 2
$CATALINA_HOME/bin/shutdown.sh
ps -ef | grep $CATALINA_HOME | grep -v grep | awk '{print $2}' | xargs echo
ps -ef | grep $CATALINA_HOME | grep -v grep | awk '{print $2}' | xargs kill -9
;;
restart)
echo "restarting tomcat"
$0 stop
$0 start
;;
*)
echo "Usage: $1 {start|stop}"
;;
esac
exit 0
脚本
将脚本放到/etc/init.d/目录下面
将脚本赋执行权限chmod +x /etc/init.d/xxx
命令
启动应用命令 service xxx start
停止应用命令 service xxx stop
重启应用命令 service xxx restart