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
相关推荐
历程里程碑1 小时前
Linxu14 进程一
linux·c语言·开发语言·数据结构·c++·笔记·算法
baidu_huihui1 小时前
`sudo DNF` 是 Linux 系统中以管理员权限执行 DNF 包管理命令的标准方式
linux·dnf
峥嵘life1 小时前
Android 16 EDLA测试STS模块
android·大数据·linux·学习
代码AC不AC2 小时前
【Linux】进程程序替换
linux·进程·程序替换
Zach_yuan2 小时前
UDP网络编程:从入门到精通
linux·网络·网络协议·udp
_叶小格_2 小时前
cp、scp、rsync命令详解
linux·运维·服务器·ubuntu·centos·运维开发
wheeldown2 小时前
【Linux网络编程】 Linux TCP网络编程:客户端开发+守护进程实战
linux·网络·tcp/ip
永不复还2 小时前
linux 使用Xcb监听键盘鼠标输入
linux·x11·xcb
mango_mangojuice2 小时前
Linux学习笔记 1.19
linux·服务器·数据库·笔记·学习
i建模2 小时前
linux断点续传下载文件
linux·运维·服务器