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
相关推荐
程序员JerrySUN23 分钟前
Linux 内核内存管理子系统全面解析与体系构建
java·linux·运维
rui锐rui1 小时前
大模型模型部署和暴露接口
linux·运维·服务器
孙克旭_1 小时前
day030-Shell自动化编程-函数
linux·运维·自动化
地衣君10 小时前
RISC-V 开发板 + Ubuntu 23.04 部署 open_vins 过程
linux·ubuntu·risc-v
5:0010 小时前
云备份项目
linux·开发语言·c++
码农101号11 小时前
Linux中shell编程表达式和数组讲解
linux·运维·服务器
云道轩11 小时前
升级centos 7.9内核到 5.4.x
linux·运维·centos
是小满满满满吗11 小时前
传输层:udp与tcp协议
linux·服务器·网络
爱学习的小道长11 小时前
Ubuntu Cursor升级成v1.0
linux·运维·ubuntu
EelBarb12 小时前
seafile:ubuntu搭建社区版seafile12.0
linux·运维·ubuntu