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
相关推荐
不知几秋3 小时前
数字取证-内存取证(volatility)
java·linux·前端
欧先生^_^6 小时前
Linux内核可配置的参数
linux·服务器·数据库
海尔辛6 小时前
学习黑客5 分钟读懂Linux Permissions 101
linux·学习·安全
王RuaRua7 小时前
[数据结构]5. 栈-Stack
linux·数据结构·数据库·链表
曼岛_8 小时前
[架构之美]linux常见故障问题解决方案(十九)
linux·运维·架构
tan180°8 小时前
Linux进程信号处理(26)
linux·c++·vscode·后端·信号处理
大神的风范8 小时前
从0开始学linux韦东山教程第三章问题小结(4)
linux·服务器
sz66cm8 小时前
Linux基础 -- SSH 流式烧录与压缩传输笔记
linux·笔记·ssh
YOYO--小天9 小时前
RS485和RS232 通信配置
linux·嵌入式硬件
Lw老王要学习9 小时前
Linux数据库篇、第一章_02_MySQL的使用增删改查
linux·运维·数据库·mysql·云计算·it