Search code examples
systemd

systemd : two services are running together


I use a simple script

[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

then when typing

systemctl --user status name.service

i get two identical process running in parallel

● 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/[email protected]/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

Since i have one ExecStart i don't understand why i get two process running in parallel.


Solution

  • The main process (PID 1625) is most probably forking another process (PID 1627). To check that the parent process of 1627 is 1625: ps -o ppid 1627