欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

tomcat启停脚本

程序员文章站 2022-08-08 16:41:01
脚本存放目录 /etc/init.d/ /etc/init.d/tomcat restart 重启/etc/init.d/tomcat start 启动/etc/init.d/tomcat stop 停止 ......

脚本存放目录 /etc/init.d/

#!/bin/bash
# description: tomcat7 start stop restart
# processname: tomcat7
# chkconfig: 234 20 80

catalina_home=/sdata/software/apache-tomcat-8.5.23

case $1 in
    start)
        sh $catalina_home/bin/startup.sh
        ;;
    stop)
        ps -e|grep java|awk '{print "kill -9 "$1}'|sh
        # sh $catalina_home/bin/shutdown.sh
        ;;
    restart)
        ps -e|grep java|awk '{print "kill -9 "$1}'|sh
        sleep 3
        # sh $catalina_home/bin/shutdown.sh
        sh $catalina_home/bin/startup.sh
        ;;
    *)
        echo 'please use : tomcat {start | stop | restart}'
    ;;
esac
exit 0

/etc/init.d/tomcat restart 重启
/etc/init.d/tomcat start    启动
/etc/init.d/tomcat stop    停止