zoukankan      html  css  js  c++  java
  • /etc/systemd/system和/lib/systemd/system的区别

    搬运文

    1.1 [/usr]/lib/systemd/system/ (软件包安装的单元)

    The expectation is that /lib/systemd/system is a directory that should only contain systemd unit files which were put there by the package manager (YUM/DNF/RPM/APT/etc).

    1.2 /etc/systemd/system/(系统管理员安装的单元, 优先级更高)

    Files in /etc/systemd/system are manually placed here by the operator of the system for ad-hoc software installations that are not in the form of a package. This would include tarball type software installations or home grown scripts.

    2. 优先级

    systemd的使用大幅提高了系统服务的运行效率, 而unit的文件位置一般主要有三个目录:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Table 1.  Load path when running in system mode (--system).
    ┌────────────────────────┬─────────────────────────────┐
    │Path │ Description │
    ├────────────────────────┼─────────────────────────────┤
    │/etc/systemd/system │ Local configuration │
    ├────────────────────────┼─────────────────────────────┤
    │/run/systemd/system │ Runtime units │
    ├────────────────────────┼─────────────────────────────┤
    │/lib/systemd/system │ Units of installed packages │
    └────────────────────────┴─────────────────────────────┘

    这三个目录的配置文件优先级依次从高到低,如果同一选项三个地方都配置了,优先级高的会覆盖优先级低的。

    系统安装时,默认会将unit文件放在/lib/systemd/system目录。如果我们想要修改系统默认的配置,比如nginx.service,一般有两种方法:

    1. /etc/systemd/system目录下创建nginx.service文件,里面写上我们自己的配置。
    2. /etc/systemd/system下面创建nginx.service.d目录,在这个目录里面新建任何以.conf结尾的文件,然后写入我们自己的配置。推荐这种做法。

    /run/systemd/system这个目录一般是进程在运行时动态创建unit文件的目录,一般很少修改,除非是修改程序运行时的一些参数时,即Session级别的,才在这里做修改。

    参考:https://www.dazhuanlan.com/2020/03/14/5e6cb299378a9/

  • 相关阅读:
    拥有自己的代码生成器—Newlife.XCode模板编写教程
    基于Newlife.XCode的权限系统(含数据集权限)【设计篇】
    拥有自己的代码生成器—NewLife.XCode代码生成器分析
    利用javascript来转换GB2312到UNICONDE &#形式
    和荣笔记 从 Unicode 到 GB2312 转换表制作程式
    如何做SVN迁移
    和荣笔记 GB2312 字符集和编码说明
    asp对象化之:基于adodb.stream的文件操作类
    Unicode 汉字内码表
    微软建议的ASP性能优化28条守则 之三
  • 原文地址:https://www.cnblogs.com/xzlive/p/15180969.html
Copyright © 2011-2022 走看看