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
相关推荐
特种加菲猫23 分钟前
构建完整工具链:GCC/G++ + Makefile + Git 自动化开发流程
linux·笔记·git·自动化
李少兄3 小时前
CentOS系统下前后端项目部署攻略
linux·运维·centos
Two_brushes.6 小时前
【Linux】线程机制深度实践:创建、等待、互斥与同步
linux·运维·服务器·多线程
设计师小聂!8 小时前
Linux系统中部署Redis详解
linux·运维·数据库·redis
kfepiza8 小时前
Debian-10编译安装Mysql-5.7.44 笔记250706
linux·数据库·笔记·mysql·debian·bash
努力做小白9 小时前
Linux驱动11 --- buildroot&杂项驱动开发方法
linux·运维·驱动开发·单片机·嵌入式硬件
帽儿山的枪手10 小时前
追踪网络流量就这么简单 | 进阶篇 | conntrack
linux·windows·网络协议
哈哈浩丶10 小时前
Linux驱动开发1:设备驱动模块加载与卸载
linux·运维·驱动开发
Bulestar_xx10 小时前
20250711_Sudo 靶机复盘
linux·安全·web安全
一位搞嵌入式的 genius10 小时前
暑期自学嵌入式——Day01(C语言阶段)
linux·嵌入式c语言