Linux系统下tomcat服务自动重启

1.修改系统启动时脚本文件

bash 复制代码
vi /etc/rc.d/rc.local
bash 复制代码
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
export JAVA_HOME=/home/jdk1.8.0_231
/home/apache-tomcat-8.5.68/bin/shutdown.sh
/home/apache-tomcat-8.5.68/bin/startup.sh

注意:脚本可能报错找不到java环境,所以加上export JAVA_HOME=/home/jdk1.8.0_231,另外tomcat需要先关闭再启动,不然进程一直存在导致启动失败

2.检查rc.local服务是否启动

bash 复制代码
 systemctl list-unit-files|grep rc.local
 # static表示已开启
 # disable未开启 如果没开启执行下面命令
 systemctl start rc.local.service

3.给文件授权

bash 复制代码
chmod +x /etc/rc.d/rc.local

4.关闭tomcat,手动执行脚本,看是否启动

bash 复制代码
sudo /etc/rc.d/rc.local

5.服务器重启测试

bash 复制代码
reboot
相关推荐
BD_Marathon13 分钟前
【Zookeeper】搭建Zookeeper服务器
linux·服务器·zookeeper
Bruce_Liuxiaowei13 分钟前
Windows安全事件4625分析:检测登录失败与防范暴力破解
运维·windows·安全·网络安全
星尘库18 分钟前
怎么实现js混淆加密 每隔一段时间 会失效 需要重新加密使用
java·服务器·前端
庚昀◟28 分钟前
Wsl系统下使用Ubuntu下载官网Nginx并加入系统服务
linux·nginx·ubuntu
猿大叔~29 分钟前
面试必问!Linux 下 C/C++ 内存对齐深度解析:从底层原理到实战避坑
linux·c语言·面试
a***560640 分钟前
Knife4j文档请求异常(基于SpringBoot3,查找原因并解决)
java·服务器·数据库
DFT计算杂谈1 小时前
Abinit-10.4.7安装教程
linux·数据库·python·算法·matlab
我科绝伦(Huanhuan Zhou)1 小时前
MySQL运维必备:24个核心监控参数(含查询语句+异常处理)
运维·数据库·mysql
python百炼成钢1 小时前
44.Linux RTC
linux·运维·实时音视频
REDcker1 小时前
软件开发者需要关注CPU指令集差异吗?
linux·c++·操作系统·c·cpu·指令集·加密算法