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
相关推荐
_w_z_j_7 小时前
Linux----线程互斥与同步
linux·运维·开发语言
风华同学7 小时前
【Linux驱动篇】字符设备驱动开发
linux·运维·驱动开发
wxh_无香花自开7 小时前
Linux 笔记:rpm命令
linux·运维·笔记·rpm
张童瑶8 小时前
Linux SSH配置密钥文件及免密登录
linux·运维·ssh
tianyuanwo8 小时前
Linux密码加密技术深度解析:从盐值到加密算法的完整指南
linux·密码加密
vortex58 小时前
Bash 替换机制(三):变量替换
linux·开发语言·bash
松涛和鸣8 小时前
34、 Linux IPC进程间通信:无名管道(Pipe) 和有名管道(FIFO)
linux·服务器·c语言·网络·数据结构·数据库
小虾米vivian8 小时前
dmetl5 web管理平台 监控-流程监控 看不到运行信息
linux·服务器·网络·数据库·达梦数据库
TG:@yunlaoda360 云老大8 小时前
如何将外部镜像文件导入华为云国际站代理商的IMS服务?
linux·运维·华为云
怀旧,8 小时前
【Linux系统编程】13. Ext系列⽂件系统
android·linux·缓存