Service

systemctl 強制命令與之前

  • May 28, 2019

我想創建一個systemctl掛載所需分區的服務lighttpd。在my-service.service文件中,我寫了以下內容:

[Unit]
Before=lighttpd

[Service]
ExecStart=/home/user/mount_script
Type=notify
User=user
Group=user

[Install]
WantedBy=multi-user.target

但是當我想啟用它時,我列印了以下錯誤syslog

systemd[1]: Reloading.
systemd[1]: /etc/systemd/system/my-service.service:2: Failed to add dependency on lighttpd, ignoring: Invalid argument

我不明白如何在…lighttpd之後強制啟動my-service

從手冊:

Before=: The units listed in this directive will not be started
        until the current unit is marked as started if they are
        activated at the same time. This does not imply a dependency
        relationship and must be used in conjunction with one of the
        above directives if this is desired.

單位的名稱是lighttpd.service,而不僅僅是lighttpd,所以這是您需要指定的。

引用自:https://serverfault.com/questions/969163