linux 开机自启 rc.local

rc.local 是启动加载文件

例1. compose启动Harbor

  • 写一个开启自动启动的脚本

    [root@harbor harbor]# vim startall.sh  
    #!/bin/bash 
    cd /root/harbor
    docker-compose stop && docker-compose start
    
  • 给脚本权限

    chmod +x startall.sh
    chmod +x /etc/rc.d/rc.local		#ll 查看rc.local有没有权限,默认没有,需要添加
    
  • 在rc.local文件末尾添加需要执行的脚本的绝对路径

    [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
    
    

相关推荐

  1. linux redis 开机

    2024-05-02 13:54:01       38 阅读
  2. Linux配置elasticsearch开机

    2024-05-02 13:54:01       39 阅读
  3. linux 开机 rc.local

    2024-05-02 13:54:01       34 阅读
  4. linux 设置nginx开机

    2024-05-02 13:54:01       27 阅读
  5. linux 设置开机终端,并自动执行命令

    2024-05-02 13:54:01       35 阅读
  6. Ubuntu开机redis

    2024-05-02 13:54:01       57 阅读
  7. Kafka开机脚本

    2024-05-02 13:54:01       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-02 13:54:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-02 13:54:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-05-02 13:54:01       87 阅读
  4. Python语言-面向对象

    2024-05-02 13:54:01       96 阅读

热门阅读

  1. k8s中同一个namespace的作用

    2024-05-02 13:54:01       37 阅读
  2. Spring 条件化Bean装配:深入理解 @Conditional 注解

    2024-05-02 13:54:01       38 阅读
  3. leetcode 174.地下城游戏

    2024-05-02 13:54:01       38 阅读
  4. Fabric,一个简洁远程系统管理Python库

    2024-05-02 13:54:01       35 阅读
  5. 2024-05-01 区块链-比特币-相关文档

    2024-05-02 13:54:01       36 阅读
  6. Dockerfile 里 ENTRYPOINT 和 CMD 的区别

    2024-05-02 13:54:01       31 阅读
  7. 【SQL】ACID事务与隔离级别

    2024-05-02 13:54:01       25 阅读
  8. python 学习: 矩阵运算

    2024-05-02 13:54:01       33 阅读