我的新 systemd 脚本的“无法识别的服务”

spr*_*aff 2 ubuntu systemd

我创建了一个新的 systemd 脚本 /etc/systemd/system/foo.service

[Unit]
Description="My foo script"
Before=network-pre.target
Wants=network-pre.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/foo
Run Code Online (Sandbox Code Playgroud)

当我跑步service start fooservice start foo.service

start: unrecognized service
Run Code Online (Sandbox Code Playgroud)

怎么了?Ubuntu 16.04

use*_*686 5

service命令将对象放在首位:

service foo start
Run Code Online (Sandbox Code Playgroud)

systemctl命令执行相反的操作:

systemctl start foo
Run Code Online (Sandbox Code Playgroud)