CentOS7开机自动执行脚本

操作步骤

第一步:新建一个脚本run-java.sh,例如:开机自动执行java程序
#! /bin/bash

# 运行java程序
java -jar /lmes/deployee/backend/ies-0.0.1-SNAPSHOT.jar &
1234
第二步:run-java.sh 脚本添加可执行权限
chmod +x run-java.sh
1
第三步:执行如下命令将/etc/rc.d/rc.local文标记为可执行文件

centos7中,/etc/rc.d/rc.local文件的权限被降低了,

chmod +x /etc/rc.d/rc.local
1
第四步:打开/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

# 执行java启动脚本
/lmes/auto_shell_script/run-java.sh
12345678910111213141516

转至:https://blog.csdn.net/github_38336924/article/details/112304663

相关推荐

  1. CentOS7开机自动执行脚本

    2024-01-27 01:36:02       59 阅读
  2. centos 7 MySQL 离线一键自动安装脚本

    2024-01-27 01:36:02       35 阅读
  3. Linux开机自动执行自定义脚本或命令

    2024-01-27 01:36:02       56 阅读
  4. centos将sh文件设置为开机自动执行

    2024-01-27 01:36:02       49 阅读
  5. 如何让centOS开机自动执行某些命令

    2024-01-27 01:36:02       38 阅读
  6. centos7 安装EFK脚本

    2024-01-27 01:36:02       62 阅读
  7. centos 7 添加启动脚本

    2024-01-27 01:36:02       37 阅读
  8. linux centos 定时任务,执行shell脚本

    2024-01-27 01:36:02       42 阅读

最近更新

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

    2024-01-27 01:36:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-27 01:36:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-27 01:36:02       87 阅读
  4. Python语言-面向对象

    2024-01-27 01:36:02       96 阅读

热门阅读

  1. 算法37:最大矩形(力扣84、85题)---单调栈

    2024-01-27 01:36:02       55 阅读
  2. KMean 聚类

    2024-01-27 01:36:02       55 阅读
  3. LED闪烁

    2024-01-27 01:36:02       53 阅读
  4. live555搭建流式rtsp服务器

    2024-01-27 01:36:02       60 阅读
  5. openssl3.2/test/certs - 075 - non-critical unknown extension

    2024-01-27 01:36:02       49 阅读
  6. Ubuntu环境vscode配置Log4cplus库

    2024-01-27 01:36:02       62 阅读
  7. 2024美赛数学建模F题思路代码模型

    2024-01-27 01:36:02       52 阅读
  8. this.$copyText;vue-clipboard2作用;vue-clipboard2剪切板

    2024-01-27 01:36:02       50 阅读