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
相关推荐
☆璇13 分钟前
【Linux】进程概念(下)
linux·运维·服务器
摘星编程17 分钟前
Linux 日志分析:用 ELK 搭建个人运维监控平台
linux·运维·elk·系统监控·性能优化维监
haogexiaole22 分钟前
网络操作系统与分布式操作系统的区别
linux
两袖清风99826 分钟前
【Linux】CentOS7安装教程
linux·运维·服务器
硬核子牙30 分钟前
mount藏着的Linux内核的秘密
linux
歪比巴卜__33 分钟前
【系列文章】Linux中的并发与竞争[04]-信号量
linux
東雪蓮☆36 分钟前
LVS 负载均衡群集
linux·运维·服务器·负载均衡·lvs
和煦的春风1 小时前
性能案例分析 | Waiting for GPU completion
android·linux
lybugproducer2 小时前
深入 Linux 文件系统:从数据存储到万物皆文件
linux
烦躁的大鼻嘎2 小时前
【Linux】深入Linux多线程架构与高性能编程
linux·运维·服务器·开发语言·c++·ubuntu