【问题标题】:Systemd unit file works manually but not on bootSystemd 单元文件手动工作,但不能在启动时工作
【发布时间】:2017-12-17 09:20:46
【问题描述】:

我制作了一个简单的 systemd 服务文件来在启动时运行命令:

[Unit]
Description=Executable Service
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/path/to/command

它只需要在启动时运行一次。然后我启用了它:

systemctl enable executable.service

systemctl is-enabled executable.service
enabled

然后我重新启动服务器(它运行的是 CentOS 7.3)并且它没有运行,我只是得到:

systemctl status executable.service
● executable.service - Executable Service
   Loaded: loaded (/usr/lib/systemd/system/executable.service; enabled; vendor preset: disabled)
   Active: inactive (dead)

一旦我手动启动服务:

systemctl start executable.service

它可以正常工作,就像我期望的那样。

【问题讨论】:

    标签: systemd


    【解决方案1】:

    您还必须将其安装到目标。 IE。添加以下部分:

    [Install]
    WantedBy=default.target
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-10
      • 2020-11-02
      • 2018-05-06
      • 1970-01-01
      • 2021-05-14
      相关资源
      最近更新 更多