I run a system service with the following config my_script.service
:
[Unit]
Description=My demo program.
[Service]
User=myname
ExecStart=/my_scripts/some_async_python_script.py
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
Before running I would do this once: sudo systemctl daemon-reload
and
sudo systemctl enable my_script.service
and then I would start like so: sudo systemctl start my_script.service
So far this work well.
The problem I have is that when I stop it with sudo systemctl stop my_script.service
and then do htop
I can see /my_scripts/some_async_python_script.py
still running.
I can see it has a parent process. When I kill the child process, it's dead (i.e. I don't need to kill the parent process).
My question is: Why is my service command still running even though I have stopped the service?