Linux系统下tomcat服务自动重启

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

vi /etc/rc.d/rc.local
#!/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服务是否启动

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

3.给文件授权

chmod +x /etc/rc.d/rc.local

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

sudo /etc/rc.d/rc.local

5.服务器重启测试

reboot

相关推荐

  1. Linux系统tomcat服务自动

    2024-04-05 10:12:04       34 阅读
  2. Linux登录/自动执行

    2024-04-05 10:12:04       64 阅读
  3. Linux监听某个进程,自动

    2024-04-05 10:12:04       29 阅读
  4. linux设置Nginx自动

    2024-04-05 10:12:04       23 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-05 10:12:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-05 10:12:04       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-05 10:12:04       82 阅读
  4. Python语言-面向对象

    2024-04-05 10:12:04       91 阅读

热门阅读

  1. 每天学习一个Linux命令之umount

    2024-04-05 10:12:04       36 阅读
  2. P1776宝物筛选

    2024-04-05 10:12:04       38 阅读
  3. Day1 单调数据结构

    2024-04-05 10:12:04       28 阅读
  4. 循环控制语句的实际应用(2)

    2024-04-05 10:12:04       34 阅读
  5. 安卓APP的开发:为了安全的设计

    2024-04-05 10:12:04       39 阅读
  6. C++11:lambda表达式 & 包装器

    2024-04-05 10:12:04       30 阅读
  7. node.js 常用命令

    2024-04-05 10:12:04       41 阅读
  8. Docker 部署war

    2024-04-05 10:12:04       33 阅读
  9. 解决跨域的几种方法

    2024-04-05 10:12:04       37 阅读