Centos7.3将tomcat服务设置为开机自启动

vim /etc/init.d/tomcat

 粘贴保存

#!/bin/bash
# description: Tomcat7 Start Stop Restart
# processname: tomcat7
# chkconfig: 234 20 80

CATALINA_HOME=/usr/local/tomcat

case $1 in
    start)
        sh $CATALINA_HOME/bin/startup.sh
        ;;
    stop)
        sh $CATALINA_HOME/bin/shutdown.sh
        ;;
    restart)
        sh $CATALINA_HOME/bin/shutdown.sh
        sh $CATALINA_HOME/bin/startup.sh
        ;;
    *)
        echo 'please use : tomcat {start | stop | restart}'
    ;;
esac
exit 0

 授予权限

chmod 775  /etc/init.d/tomcat

执行脚本,启动、停止 和 重启服务

启动:service tomcat start
停止:service tomcat stop
重启:service tomcat restart

Tomcat 配置开机自启动

向chkconfig添加 tomcat 服务的管理

chkconfig --add tomcat

设置tomcat服务自启动

chkconfig tomcat on

查看tomcat的启动状态

chkconfig --list | grep tomcat

关闭tomcat服务自启动:

chkconfig tomcat off

删除tomcat服务在chkconfig上的管理:

hkconfig –del tomcat
发布了100 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/csdn9228/article/details/103578430