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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章