博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
解决centos系统自定义在rc.local中的脚本不能执行问题小记
阅读量:7111 次
发布时间:2019-06-28

本文共 1376 字,大约阅读时间需要 4 分钟。

时间: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. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    #!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. 1
    rc.
    local

  6. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #!/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
本文转自 南非波波 51CTO博客,原文链接:http://blog.51cto.com/nanfeibobo/1689053,如需转载请自行联系原作者
你可能感兴趣的文章
Oracle与MySQL连接
查看>>
Element-UI使用笔记
查看>>
互信息原理
查看>>
struts2 url 配置问题
查看>>
spring2.5.6+Hibernate3+RMI整合
查看>>
MyBatis动态传入表名,字段名参数的解决办法
查看>>
Powershell DSC安装Java
查看>>
python list排序
查看>>
我的友情链接
查看>>
历史的思考
查看>>
python 输出指定年月份的日历!
查看>>
Redis详解(一)
查看>>
LAMP详解(一)
查看>>
rhel6 无人值守安装(dhcp+tftp+ftp+ks)
查看>>
linux集群之LVS DR模型简单实现
查看>>
Android天天数钱游戏源码
查看>>
跪求解决
查看>>
如何使用Powershell脚本监控Exchange2010(三) Archive邮箱容量和使用情况的发布
查看>>
zabbix 网络监控 (一) -- lamp 搭建zabbix2.0.5
查看>>
Ubuntu上使用Webmin进行Linux的远程管理
查看>>