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
相关推荐
AlanBruce5 小时前
摩尔信使MThings功能综述与应用使用指南
linux·自动化·plc·mthings·摩尔信使
陈陈CHENCHEN9 小时前
【Linux】服务器根目录磁盘扩容操作记录
linux·运维·服务器
GeW10 小时前
RHCE快速拿证全攻略:考点拆解+实验强化+时间规划,一次通关
linux
码农小韩11 小时前
Linux应用开发(八)——TCP/IP网络编程基础
linux·嵌入式软件开发·linux操作系统·嵌入式操作系统·linux网络编程·linux应用
迷途之人不知返11 小时前
【进程】-5-进程优先级
linux
fengyehongWorld12 小时前
Linux squid搭建基础代理服务器
linux·运维·服务器
木白CPP12 小时前
Linux DMA驱动详解(二)-----DMA的使用者
java·linux·运维
赵民勇12 小时前
systemd-socket-activate命令详解
linux·运维
Cx330❀13 小时前
【Linux网络】网络层 IP 协议:从网段划分到内核源码解析
大数据·linux·服务器·网络·tcp/ip·性能优化·langchain
企鹅的蚂蚁13 小时前
LubanCat RK3588 实时 Linux 开发(七):YT6801 PCIe 网卡驱动移植与 vermagic 排查
linux·rk3588·linux驱动·yt6801·pcie网卡·vermagic