Systemd常用教程

systemd是linux用来守护进程的。d即daemon(守护进程) 我们通过systemctl命令管理守护进程. systemctl 命令 1 sudo systemctl start/stop/enable/reload unit.service 使用上述命令开启/停止/设置自启动/重载 某个服务。 1 sudo systemctl daemon-reload 重载修改过的配置文件. Unit systemd对每项系统资源称为Unit 一共有12种Unit. Service Unit:系统服务 Target Unit:多个 Unit 构成的一个组 Device Unit:硬件设备 Mount Unit:文件系统的挂载点 Automount Unit:自动挂载点 Path Unit:文件或路径 Scope Unit:不是由 Systemd 启动的外部进程 Slice Unit:进程组 Snapshot Unit:Systemd 快照,可以切回某个快照 Socket Unit:进程间通信的 socket Swap Unit:swap 文件 Timer Unit:定时器 本文中我们只关注用的比较多的Service和Timer Unit 配置 Unit配置文件通常在/usr/lib/systemd/system/中。 一个.service文件: 1 2 3 4 5 6 7 8 [Unit] Description= # 描述 Documentation= # 文档地址 Requires= #依赖于其他service [Service] ExecStart= # 执行地址 [Install] WantedBy= # target Requires中写的是其他unit,如果其他unit未运行,本unit将启动失败。 WantedBy一般写的是multi-user....

2022/12/02 · updated 2023/02/21 · 114 words · Finley Ge
晋ICP备2022008114