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
相关推荐
Rabitebla8 小时前
【Linux 底层原理】进程(十):进程等待详解---从僵尸进程到 wait、waitpid 与 status
linux·c++·笔记·学习·visual studio
Android系统攻城狮13 小时前
Linux FFmpeg深度解析之avcodec_default_get_encode_buffer调用流程与实战(二十八)
linux·运维·服务器·ffmpeg·车载音视频·ffmpeg音视频
程序员初一13 小时前
8080 打不开的四层定位:监听地址、ufw、DOCKER 链、安全组
linux·ssh
程序开发阿元13 小时前
swappiness 60 和 10 差在哪:一台 1C1G 的三轮对比
linux·ssh
无足鸟ICT13 小时前
【RHCA+】mpstat命令(监控CPU)
linux
GeW14 小时前
新质生产力Linux和数据库为啥这么关键
linux
番茄啊15 小时前
linux 开启xftp连接
linux·运维·服务器
CodeYp201915 小时前
第1讲:Linux 基础指令
linux·指令
李松桃15 小时前
基于端口号的服务配置
linux·nginx-核心模块配置
CodeYp201920 小时前
第14讲:mmap 实现文件 LRU 缓存
linux·lru·mmap