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
相关推荐
梁正雄33 分钟前
5、python 模块与包
linux·服务器·python
axihaihai42 分钟前
腾讯云镜像仓库访问问题
linux·服务器·腾讯云
xuanloyer42 分钟前
linux基础学习--学习bash
linux·学习·bash
happytree00143 分钟前
suricata之Threads
linux
大海里的番茄1 小时前
让操作系统的远程管理更简单用openEuler+cpolar
linux·c语言·c++
赖small强1 小时前
【音视频开发】CMOS Sensor图像采集原理及Linux主控ISP处理流程
linux·音视频·cmos·isp·v4l2
津渡7411 小时前
【技术实战】Linux 服务器网络流量统一配置(TUN模式):解决 Docker/开发环境连接难题
linux
胖咕噜的稞达鸭1 小时前
基础IO 文件在内核中是怎么被管理的 重定向的含义 在自定义shell中加入重定向
linux·c++·git·腾讯云·visual studio·csdn开发云
天宁1 小时前
Ubuntu 一键切换吉林大学镜像源
linux·ubuntu
代码栈上的思考1 小时前
Linux 核心基础实操(含远程登录、编辑器、用户管理等)
linux·运维·服务器