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

  • 相关阅读:
    禅道的安装
    项目管理必看的几个网站
    禅道管理中的项目管理--组织进行任务分解
    Redis--Springboot使用
    Mapper.xml--配置map<String, List<String>>输入
    SpringBoot-Dubbo、Zk
    高并发--并发编程的三大辅助类
    笔试-2020年西山居Java笔试题(补上,一直忘记补上了)
    HttpWebRequest.GetRequestStream方法timeout【第3次操作时就超时】的原因及解决办法
    洛谷 P2613 【模板】有理数取余(高精度取余,逆元)
  • 原文地址:https://www.cnblogs.com/xzlive/p/15178974.html
Copyright © 2020-2023  润新知