sh脚本开机自启动

CentOS系统和Redhat系统如下:
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
/root/Desktop/start.sh

“sourece /root/Desktop/start.sh”为要添加开机自启动的脚本,并且要给“/root/Desktop/start.sh”赋予执行权限(chmod +x /root/Desktop/start.sh)
2.chmod 777 rc.local
3.重启系统后就会开始执行预设置执行的脚本。(此种自启动方式不会在GUI界面显示执行的具体进程)**

posted on 2022-04-10 21:57  韩山隐士  阅读(501)  评论(0编辑  收藏  举报