[systemd-devel] Run cleanup service on stop

Andrei Borzenkov arvidjaar at gmail.com
Wed Nov 4 01:41:53 PST 2015

03.11.2015 09:21, Kai Hendry пишет:
> Hi there guys,
> I have a service where it's important that it cleans up *after* it's
> run. In fact it's probably a good idea to make sure it's clean *before*
> it's run too.
> I got as far as:
> After=clean.service
> Requires=clean.service
> But that does not seem to clean on stop (say if the machine is shutting
> down). What am I missing?
> My alternative approach which seems to work is to use:
> ExecStartPre=...
> ExecStopPost=...
> But it looks a little ugly.

Why? It sounds like exact use case for Pre/Post commands.

More information about the systemd-devel mailing list