linux 开机自启 rc.local

rc.local 是启动加载文件

例1. compose启动Harbor

  • 写一个开启自动启动的脚本

    bash 复制代码
    [root@harbor harbor]# vim startall.sh  
    #!/bin/bash 
    cd /root/harbor
    docker-compose stop && docker-compose start
  • 给脚本权限

    bash 复制代码
    chmod +x startall.sh
    chmod +x /etc/rc.d/rc.local		#ll 查看rc.local有没有权限,默认没有,需要添加
  • 在rc.local文件末尾添加需要执行的脚本的绝对路径

    bash 复制代码
    [root@k8s-master harbor]# vim /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
    /bin/bash /root/harbor/startall.sh
相关推荐
Cx330❀1 小时前
【MySQL基础】一文吃透“表的约束”:从 Null/Default 到主外键的终极安全法则
linux·服务器·数据库·c++·mysql·安全
程序员JerrySUN2 小时前
Jetson 刷机深度解析:flash.sh vs l4t_initrd_flash.sh(含安全与磁盘加密对比)
linux·网络·arm开发·安全·系统安全
六点_dn2 小时前
Linux学习笔记-printf命令
linux·运维·算法
蜡台2 小时前
Linux Python 安装使用
linux·运维·服务器
欧神附体1233 小时前
在虚拟机中添加网卡,修改网卡名并关闭SElinux
linux·服务器·网络
brave_zhao5 小时前
openEuler下安装tar包解压工具
linux·服务器·数据库
小宏运维有点菜5 小时前
JumpServer
linux·运维
是个西兰花6 小时前
Linux:死锁与生产者消费者模型解析
linux·运维·服务器·c++·死锁·生产者消费者模型
RisunJan6 小时前
Linux命令-rsync(远程/本地文件同步 —— 增量传输的备份与镜像神器)
linux·运维·服务器
爆浇牛肉面6 小时前
Linux进阶命令:测开必学的curl和jq
linux