systemctl force 命令与之前

systemctl force 命令与之前

我想创建一个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.

答案1

单位名称是lighttpd.service,而不仅仅是lighttpd,因此这是您需要指定的。

相关内容