centos7中的/etc/rc.local文件权限问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7中的/etc/rc.local文件权限问题相关的知识,希望对你有一定的参考价值。

参考技术A 在centos7中,/etc/rc.local文件默认没有可执行权限

如果要执行一些命令,需要加入可执行权限

# ll /etc/rc.local

lrwxrwxrwx. 1 root root 13 Sep  4 16:01 /etc/rc.local -> rc.d/rc.local

# ll /etc/rc.d/rc.local

-rw-r--r--. 1 root root 507 Sep  7 21:51 /etc/rc.d/rc.local  # 没有可执行的权限

增加可执行权限

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

centos7 开机/etc/rc.local不执行命令的问题

centos7 开机/etc/rc.local 不执行的问题

    公司现在要求线上的服务器统一使用centos7,最近发现centos7 /etc/rc.local不会开机执行,认真看了下/etc/rc.local文件内容的就发现了问题的原因了

[[email protected] ~]# cat /etc/rc.local

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd servicesor udev rules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallelexecution 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

#nagios nrpe process cmd by hejp 2016-4-1

/usr/local/nagios/bin/nrpe -c/usr/local/nagios/etc/nrpe.cfg -d

 

只需要为文件添加执行权限就解决问题了:

[[email protected] ~]# ps -ef|grep nrpe

root      2475   2455  0 20:55 pts/0    00:00:00 grep --color=auto nrpe

[[email protected] ~]# ll /etc/rc.local        ### /etc/rc.d/rc.local没有执行权限

lrwxrwxrwx. 1 root root 13 Mar 29 12:26 /etc/rc.local-> rc.d/rc.local

[[email protected] ~]# ll /etc/rc.d/rc.local

-rw-r--r--. 1 root root 580 Mar 29 16:43/etc/rc.d/rc.local

[[email protected] ~]# chmod +x /etc/rc.d/rc.local   ### 给它加执行权限重启后就能够执行了。

[[email protected] ~]# ll /etc/rc.d/rc.local      

-rwxr-xr-x. 1 root root 580 Mar 29 16:43/etc/rc.d/rc.local


本文出自 “早起的鸟儿有虫吃” 博客,请务必保留此出处http://hejianping.blog.51cto.com/11279690/1760313

以上是关于centos7中的/etc/rc.local文件权限问题的主要内容,如果未能解决你的问题,请参考以下文章

开机启动/etc/rc.local失效无效怎么办

linux中/etc/rc.d/rc.local是啥文件

linux中/etc/rc.d/rc.local是啥文件

Ubuntu 解决 /etc/rc.local 开机启动问题

linux中/etc/rc.d/rc.local是啥文件

CentOS7 宝塔面板 MinIO安装部署/服务开机启动