将tomcat启动设置成server服务

2023-01-02 00:00:00 服务 启动 设置成

启动、重启、停止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

    原文作者:lv_code
    原文地址: https://blog.csdn.net/qq_26347283/article/details/121253417
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。

相关文章