• centos 7.1开机/etc/rc.local脚本不执行的问题


    Centos 7.1中,/etc/rc.local是一个软链接文件、指向的是/etc/rc.d/rc.local

    在Centos之前的版本我们都会将一些开机需要执行的命令加入到/etc/rc.local文件中

    但笔者今天在Centos 7.1操作系统中同在/etc/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.

    这次注意到了上面的注释内容,大致意思是rc.local文件是为了兼容性的问题而添加的

    与以前的版本引导时的并行执行相比较,这个脚本将不会在其他所有的服务后执行。如果确实需要让它执行的话

    即向之前的版本兼容的话,必须执行"chmod +x /etc/rc.d/rc.local"来确保确保这个脚本在引导时执行。

    根据注释,我们明白是因为rc.local文件没有x执行权限,笔者也查看了一下rc.local文件的属于,如下

    这时,我们给rc.local文件加上执行权限,如下

    [root@5201351 ~]# chmod +x /etc/rc.d/rc.local

    重启后发现/etc/rc.local文件里的内容能够执行了。

    看样子是Centos 版本的升级变迁,/etc/rc.local /etc/rc.d/rc.local正在被弃用的路上。

    尊重别人的劳动成果 转载请务必注明出处:http://www.cnblogs.com/5201351/p/4755200.html

  • 相关阅读:
    java中传值与传引用
    microsofr visual studio编写c语言
    openfile学习笔记
    在 Windows 和 Linux(Gnome) 环境下 从命令界面打开网页的方式
    使用vsphere client 克隆虚拟机
    route命令
    linux rpm问题:怎样查看rpm安装包的安装路径
    【leetcode】415. 字符串相加
    【leetcode】面试题 17.01. 不用加号的加法
    【leetcode】989. 数组形式的整数加法
  • 原文地址:https://www.cnblogs.com/5201351/p/4755200.html
Copyright © 2020-2023  润新知