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
相关推荐
星哥说事28 分钟前
如何将堡塔云WAF备份、迁移到新的服务器
linux
ycchenG71 小时前
缓存元数据损坏操作步骤(lvmcache修复)
linux·缓存
一乐小哥1 小时前
Docker 拉取镜像超时?别再瞎抄配置了!亲测 3 个有效镜像源 + 避坑指南
linux·docker
the sun341 小时前
从内核数据结构的角度理解socket
linux·运维·服务器
阿群今天学习了吗3 小时前
label studio 服务器端打开+xshell端口转发设置
linux·运维·服务器·笔记·python
Aczone283 小时前
Linux Framebuffer(帧缓冲)与基本 UI 绘制技术
linux·运维·ui
wdfk_prog13 小时前
[Linux]学习笔记系列 -- [arm][lib]
linux·运维·arm开发·笔记·学习
boy快快长大13 小时前
【Linux】常用命令(三)
linux·运维·服务器
ayaya_mana14 小时前
Notepad--:国产跨平台文本编辑器,Notepad++ 的理想替代方案
linux·windows·macos·编辑器·notepad·notepad--
岩屿16 小时前
.NET 应用程序 Linux下守护进程脚本编写
linux·运维·服务器·c#·.net