标签:centos7 开机/etc/rc.local不执行命令的问题
centos7 开机/etc/rc.local 不执行的问题
公司现在要求线上的服务器统一使用centos7,最近发现centos7 的/etc/rc.local不会开机执行,认真看了下/etc/rc.local文件内容的就发现了问题的原因了。
[root@YAF ~]# 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
只需要为文件添加执行权限就解决问题了:
[root@YAF ~]# ps -ef|grep nrpe
root 2475 2455 0 20:55 pts/0 00:00:00 grep --color=auto nrpe
[root@YAF ~]# 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
[root@YAF ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 580 Mar 29 16:43/etc/rc.d/rc.local
[root@YAF ~]# chmod +x /etc/rc.d/rc.local ### 给它加执行权限重启后就能够执行了。
[root@YAF ~]# 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不执行命令的问题
原文地址:http://hejianping.blog.51cto.com/11279690/1760313