systemd :两个服务 运行 在一起

systemd : two services are running together

我使用一个简单的脚本

[Unit]
Description = description here
After = multi-user.target
[Service]
type=simple
ExecStart = /usr/lib/name_deamon/CP_linux/CP_linux
Restart = on-failure
TimeoutStopSec = infinity

[Install]
WantedBy=custom.target

然后在输入时

systemctl --user status name.service

我得到两个相同的进程运行并行

● name.service - description here
 Loaded: loaded (/home/ubuntu/.config/systemd/user/name.service; enabled; vendor preset: enabled)
 Active: active (running) since Tue 2021-11-02 11:03:47 CET; 13min ago
 Main PID: 1625 (CP_linux_test.e)
  Tasks: 2 (limit: 4384)
 Memory: 14.2M
    CPU: 122ms
 CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/name.service
         ├─1625 /usr/lib/name_deamon/CP_linux_test/CP_linux_test.exe
         └─1627 /usr/lib/name_deamon/CP_linux_test/CP_linux_test.exe

因为我有一个 ExecStart,所以我不明白为什么我要并行处理两个进程 运行。

主进程 (PID 1625) 很可能正在分叉另一个进程 (PID 1627)。 查看1627的父进程是否为1625:ps -o ppid 1627