zoukankan      html  css  js  c++  java
  • /etc/profile与/etc/rc.local的区别

    一、/etc/profile 环境变量

    用户登录的时候执行sh脚本的顺序,每次登录的时候都会完全执行的

    /etc/profile.d/file
    /etc/profile
    /etc/bashrc
    /root/.bashrc
    /root/.bash_profile
    

    用户脚本,在用户登陆后执行,只有用户权限,所以只能执行用户权限下的程序,不登录就不会执行。

    二、/etc/rc.local 开机自启动

    系统脚本,系统启动后自动执行,与是否登陆无关,所以优先级高于profile,可以指定执行程序的权限

    以下是 在/etc/rc.loacl 配置的开机启动elk系列应用

    [root@test-2-45 /]# more /etc/rc.local 
    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution 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.
    
    #启动elk系统应用
    /home/elasticsearch/es_node/bin/elasticsearch.sh start
    sleep 10s
    /home/elasticsearch/es_date/bin/elasticsearch.sh start
    sleep 10s
    /usr/local/zookeeper/bin/zkServer.sh start
    sleep 10s
    /home/elasticsearch/kafka/kafka start
    sleep 10s
    /home/elasticsearch/logstash_kafka/logstash_kafka start
    sleep 10s
    /home/elasticsearch/filebeat/filebeat start
    sleep 10s
    /home/elasticsearch/kibana/kibana start
    sleep 10s
    
    touch /var/lock/subsys/local

    设置环境变量的脚本,可以放在profile.d目录下面,但开机执行任务不应该放在profile.d目录下,因为每次登陆都会执行profile.d目录下的文件,会导致重复执行,
    设置开机启动任务,应该放在rc.local中执行,它只会在系统启动时执行一次。

  • 相关阅读:
    程序员书单合集,持续整理中
    informatica9.5.1后最一步出错(ICMD_10033,INFACMD_10053)
    Informatica9.5.1配置域名错误(ICMD_10033,INFASETUP_10002,RSVCSHARED_00021)
    程序员书单_UML篇
    程序员书单_J2EE专题
    程序员书单_求职面试
    程序员书单_java专项进阶篇
    程序员书单_HTML篇
    程序员书单_数据结构和算法篇
    程序员书单_HeadFirst系列
  • 原文地址:https://www.cnblogs.com/xzlive/p/15178974.html
Copyright © 2011-2022 走看看