时间:2015.8.27

困扰了一下午的问题,晚上终于搞定,把他记录在这里


出现centos中rc.local不能自行启动的问题,大概有这么几种情况:

  1. rc.local文件没有可执行权限:添加可执行权限  (备注:/etc/rc.d/rc.local为源文件,/etc/rc.local /etc/rc3.d/S99lcoal等均为软连接文件)

  2. 缺少环境变量,因为系统启动后最后执行rc.local,但是一些系统或者用户的环境变量没有加载:解决办法:(1)在执行脚本之前添加sleep 10延迟10秒执行,但是我这边没有试验成功

              (2)在执行脚本之前添加source /etc/profile命令加载环境变量。今天下午执行node程序脚本不成功就是因为node变量的问题 

  3. 还有一种情况就是报错:我遇到的是启动rabbitmq时报:erlexec:home must be set  解决方法:在执行脚本里添加export HOME=/usr/local/erlang 


  4. #!bin/bash
    ######################################################################
    #Date:2015-08-13                                                     #
    #Author:qingbo.song                                                  #
    #E-mail:qingbo.song@apicloud.com                                     #
    #Comment:rabbitmq_start.sh                                           #
    #Path:/home/apicloud/Shell2E                                         #
    #Vesion:v1.0                                                         #
    ######################################################################
    #设置erlang家目录,否则rabbitmq不能开机自启动
    export HOME=/usr/local/erlang
    #rabbitmq start
    /usr/local/rabbitmq/sbin/rabbitmq-server
  5. rc.local


  6. #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    touch /var/lock/subsys/local
    source /etc/profile
    sh /home/shell/rabbitmq_start.sh
    #set push_start.sh
    sh /home/shell/push_start.sh
    echo never > /sys/kernel/mm/transparent_hugepage/enabled