小编Was*_*lik的帖子

“systemctl restart”和“systemctl start”有什么区别?

我有两个服务 A 和 B,其中 A 依赖于 B,这意味着 A 需要 B 提供的服务,因此在 A 的服务单元中,我将 After 和 Requires 设置为 B

After=B.service
Requires=B.service
Run Code Online (Sandbox Code Playgroud)

现在,当我停止服务 B 时,服务 A 也会停止。然后当我启动它时停止B后,服务A没有启动,我必须手动启动它。

systemctl stop B (A is also stopped)
systemctl start B (A is not started)
systemctl start A (I have to start A manually)
Run Code Online (Sandbox Code Playgroud)

但是如果服务 A 已经停止并且我重新启动服务 B,那么 B 和 A 都会由 systemctl 启动

systemctl stop A
systemctl restart B (B and A both are started)
Run Code Online (Sandbox Code Playgroud)

我的问题是我为 A 提供的服务单位类型start和之间有什么区别?restart

linux restart systemd

7
推荐指数
1
解决办法
7202
查看次数

如何获取路径的前两个目录

我在linux bash脚本中有一个变量路径.这条路可能是

/a/b/c/d/t.json
/a/b/c/d/e/f/t.json
/a/b/t.json
Run Code Online (Sandbox Code Playgroud)

我想获得前2个目录.输出应该/a/b适用于上面的所有3个示例路径.

linux bash

0
推荐指数
1
解决办法
1238
查看次数

标签 统计

linux ×2

bash ×1

restart ×1

systemd ×1