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
相关推荐
匆匆那年9671 天前
VSCode 远程 Linux 使用Codex
linux·ide·vscode
SWAGGY..1 天前
Linux系统编程:(七)Makefile入门:轻松掌握编译自动化
linux·运维·自动化
开开心心就好1 天前
免费流畅的远程控制实用工具
linux·运维·服务器·网络·智能手机·excel
黑猫学长呀1 天前
存储宝典第2篇:盲封TT wafer是什么意思?
linux·嵌入式硬件·项目·芯片·ufs·晶圆·产测
Strugglingler1 天前
【Linux 用户态操作 UART】
linux·uart
代码熬夜敲Q1 天前
ENSP 网络工程实验
linux·运维·服务器
csdn_life181 天前
OpenClaw v2026.5.12+ 高级密钥管理:使用SecretRef实现真正的隐蔽存储
linux·openclaw
Terrence Shen1 天前
Claude Code Harness 源码学习讲义
linux·学习·ubuntu
赵药师1 天前
dpkg: warning: files list file for package ‘libselinux1:amd64‘ missing;
linux·运维·服务器
STDD1 天前
Samba 文件共享:Linux 服务器与 Windows/Mac 共享文件夹
linux·服务器·windows