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中执行,它只会在系统启动时执行一次。

  • 相关阅读:
    HDU 4024 Dwarven Sniper’s hunting(数学公式 或者是二分)
    二分图最大匹配总结
    HDU 4022 Bombing (STL应用)
    HDU 1847 Good Luck in CET4 Everybody!(组合博弈)
    HDU 1556 Color the ball(树状数组)
    HDU 4023 Game(博弈)
    HDU 1406 完数(水题)
    HDU 4021 24 Puzzle
    Oracle 多表查询优化
    【编程之美】字符串移位包含的问题(续)
  • 原文地址:https://www.cnblogs.com/xzlive/p/15178974.html
Copyright © 2011-2022 走看看