centos7 开机/etc/rc.local不执行命令的问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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不执行命令的问题的主要内容,如果未能解决你的问题,请参考以下文章
解决centos7 开机/etc/rc.local 不执行的问题
centos7 开机/etc/rc.local 不执行的问题