创建tomcat文件
#!/bin/bash
# description: Tomcat9 Start Stop Restart
# processname: tomcat9
# chkconfig: 234 20 80
CATALINA_HOME=/opt/tomcat9
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