操作步骤
第一步:新建一个脚本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