• 设置rc.local设置开机自启无效


    项目中设置了/etc/init.d/rc.local 开机启动后一直没有效果,后来找到问题是由于系统中存在了两个rc.local文件,将其改为写入到文件/etc/rc.local即可
    1.判断一下rc.local有无执行权限,如果没有chmod +x一下
    2.判断rc.local所处目录,如果是/etc/init.d目录下面的需验证一下/etc/rc.local文件有没有如果有的话,判断一下是不是软连接,如果不是则只会执行/etc/rc.local文件了
    3.设置开机自启动的执行语句,如果是/etc/init.d/rc.local 一般卸载star()函数前面,如果写在最后面有可能还没执行到对应的语句就退出了;如果是/etc/rc.local 直接写在exit(0)前面即可
     
    /etc/init.d/rc.local 
     #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          rc.local
    # Required-Start:    $all
    # Required-Stop:
    # Default-Start:     2 3 4 5
    # Default-Stop:
    # Short-Description: Run /etc/rc.local if it exist
    ### END INIT INFO
     
     
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
     
    . /lib/init/vars.sh
    . /lib/lsb/init-functions
     
    do_start() {
        if [ -x /etc/rc.local ]; then
                [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
            /etc/rc.local
            ES=$?
            [ "$VERBOSE" != no ] && log_end_msg $ES
            return $ES
        fi
    }
     
    case "$1" in
        start)
        do_start
            ;;
        restart|reload|force-reload)
            echo "Error: argument '$1' not supported" >&2
            exit 3
            ;;
        stop)
            ;;
        *)
            echo "Usage: $0 start|stop" >&2
            exit 3
            ;;
    esac
    

    从注释可以看出该脚本运行在2 3 4 5的启动级别,只能处理start的参数,然后执行start,如果有/etc/rc.local文件的话则执行/etc/rc.local,

    /etc/rc.local

    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
     
    exit 0
    

      

     
    这两个脚本里面都会对应的一些注释和说明,一定要仔细看一下,很有用!
  • 相关阅读:
    supervisor管理airflow
    airflow迁移
    flume部署
    canal原理&部署
    EMR日常操作
    linux的route
    autossh
    Velocity(5)——#macro 指令
    Git(1)----Eclipse安装Git插件
    Velocity(4)——引入指令和#Parse 指令
  • 原文地址:https://www.cnblogs.com/zhaobinyouth/p/15408418.html
Copyright © 2020-2023  润新知