zoukankan      html  css  js  c++  java
  • 为什么CentOS8开机不执行rc.local

    一、有两台服务器,一台centos6,一台centos8。centos6中配置了开机启动脚本rc.local,理所当然的在centos8中也照样配置了,结果.....Centos8中的rc.local并未启动。

    二、首先执行一条检查命令:

    systemctl status rc-local

    发现它的状态是:Active: inactive (dead) 未激活

    这是什么原因?

    在Centos系统中,我们运维一般在/etc/rc.d/rc.local写入开机需要运行的命令,就可以实现系统开机启动过程,启动所需的命令,这是Centos5-6的常规做法,但是在Centos7-8采用了systemd技术,开机不会运行init进程,但是为了兼容Centos5-6版本,新版本中提供了一个rc-local的systemc服务,可以通过启动此服务,实现rc.local文件中设置的启动程序开机启动。

    所以设置一下:

    1、将 rc.local 文件设置为可执行文件:

    chmod +x /etc/rc.d/rc.local

    2、在 /usr/lib/systemd/system/rc-local.service 结尾加上:

    [Install]
    WantedBy=multi-user.target

    3、设置为开机启动

    systemctl enable rc-local

    完成。

    三、来看一下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.

    意思是:

    添加此文件是出于兼容性目的
    最好创建自己的systemd服务或udev规则来在引导期间运行脚本,而不是使用这个文件。
    与以前的版本不同,由于在引导期间并行执行,此脚本将不会在所有其他服务之后运行。
    请注意,您必须运行CHMOD+X/ETC/RC D/rc.本地'以确保在引导期间执行此脚本。

    创建启动服务传送门:https://www.cnblogs.com/hunttown/p/14872071.html

    欢迎关注我的公众号:云栖语,不一样的研发视界。
    云栖语微信公众号:change-1978
  • 相关阅读:
    OCP-1Z0-053-V12.02-367题
    OCP-1Z0-053-V12.02-16题
    OCP-1Z0-053-V12.02-21题
    OCP-1Z0-053-V12.02-368题
    OCP-1Z0-053-V12.02-356题
    VC++ 线程池(h)
    OCP-1Z0-053-V12.02-361题
    OCP-1Z0-053-V12.02-355题
    OCP-1Z0-053-V12.02-289题
    OCP-1Z0-053-V12.02-100题
  • 原文地址:https://www.cnblogs.com/hunttown/p/14871361.html
Copyright © 2011-2022 走看看