系统单元文件手动工作,但不能在启动时工作



我做了一个简单的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

它像我期望的那样毫无问题地工作。

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

[Install]
WantedBy=default.target

相关内容

最新更新