【问题标题】:What is the difference between "systemctl restart" and "systemctl start"?“systemctl restart”和“systemctl start”有什么区别?
【发布时间】:2015-05-29 13:05:08
【问题描述】:

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

After=B.service
Requires=B.service

现在,当我停止服务 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)

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

systemctl stop A
systemctl restart B (B and A both are started)

我的问题是 startrestart 对于 A 的服务单元有什么区别?

【问题讨论】:

  • 当存在依赖服务时,我找不到任何关于 systemctl restart 行为的文档。你有吗?

标签: linux restart systemd


【解决方案1】:

systemctl start:用于启动一个服务(不是持久重启)

systemctl stop:用于停止服务(不是持久重启)

systemctl restart:用于停止然后启动一个服务

【讨论】:

  • service apache2 reload有什么区别?
【解决方案2】:

您可以随时参考手册页以获得更好的理解。基本上要、要、要后区别对待。

依赖项对服务文件中的需求和需求的反应不同。

启动只是在您想使用服务时启动它,但重启主要是在对服务文件进行一些更改时完成。 请参阅此链接以更好地理解https://wiki.archlinux.org/index.php/Systemd

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2019-05-29
    • 1970-01-01
    • 2022-01-09
    • 1970-01-01
    • 2018-11-24
    • 2019-06-05
    相关资源
    最近更新 更多