I have a systemd.service that run a script who can takes a long (like a couple of hours) or short time to finish, and when the script finishes it needs to call a cleanup script. My systemd.service file uses
The user can stop the service at any time, but then the cleanup script needs to be called.
I would like the service to be seen as active while the start script is running.
At the moment I have put the cleanup script in
ExecStop and it seems to work. But sometimes I see that the service is failed, and I think that may be because of the long duration of the start script.
Can someone help me to understand how to achieve this with systemd please?