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
相关推荐
煤球王子2 分钟前
浅学文件系统4(页面缓存)
linux
peixiuhui6 分钟前
Iotgateway技术手册-1. 项目概述
linux·网关·iot·modbus·数据采集网关·iotgateway·采集软件
wdfk_prog7 分钟前
[Linux]学习笔记系列 -- [fs]sysfs
linux·笔记·学习
AllFiles17 分钟前
Linux 网络故障排查:如何诊断与解决 ARP 缓存溢出问题
linux·后端
pps-key39 分钟前
Afrog漏洞扫描器:从入门到入狱......边缘的摇摆记录(pps-key黑化版)
linux·计算机网络·安全·网络安全
学Linux的语莫1 小时前
linux的root目录缓存清理
linux·运维·服务器
oMcLin1 小时前
如何在 SUSE Linux Enterprise Server 15 上部署并优化 K3s 集群,提升轻量级容器化应用的资源利用率?
linux·运维·服务器
L_09071 小时前
【Linux】进程概念
linux
Ghost Face...1 小时前
深入解析YT6801驱动模块架构
linux·运维·服务器
比奇堡派星星2 小时前
Linux 杂项设备驱动框架详解
linux·arm开发·驱动开发