码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-04-05 10:59:56      阅读:222      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!