当前位置: 代码迷 >> 综合 >> Linux系统下设置tomcat开机自启
  详细解决方案

Linux系统下设置tomcat开机自启

热度:23   发布时间:2023-10-17 06:27:22.0

1.新建脚本文件。

[root@Lance ~]# cd /etc/init.d/
[root@Lance init.d]# vim tomcat

脚本内容如下(注意 chkconfig: 234 20 80不能省略):

#!/bin/bash
# description: Tomcat8 Start Stop Restart
# processname: tomcat8
# chkconfig: 234 20 80
CATALINA_HOME=/usr/bin/tomcat/apache-tomcat-8.5.0    #替换为你自己的tomcat安装目录
case $1 instart)sh $CATALINA_HOME/bin/startup.sh;;stop)sh $CATALINA_HOME/bin/shutdown.sh;;restart)sh $CATALINA_HOME/bin/shutdown.shsh $CATALINA_HOME/bin/startup.sh;;*)echo 'please use : tomcat {start | stop | restart}';;
esac
exit 0

执行脚本,启动、停止 和 重启服务。
启动:service tomcat start
停止:service tomcat stop
重启:service tomcat restart 

2.设置开机自启

向chkconfig添加 tomcat 服务的管理
chkconfig --add tomcat

设置tomcat服务自启动
chkconfig tomcat on

查看tomcat的启动状态
chkconfig --list | grep tomcat

 


关闭tomcat服务自启动
chkconfig tomcat off

删除tomcat服务在chkconfig上的管理
chkconfig –del tomcat

  相关解决方案