[systemd-devel] Run cleanup service on stop

Kai Hendry hendry at webconverger.com
Mon Nov 2 22:21:59 PST 2015


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. Here is my source:
http://s.natalian.org/2015-11-03/service-or-exec.tar

Be great to review/critique and suggestions for improvement. I would
like to get $HOME onto a private tmpfs going into the future, though I
am not sure how to achieve that with systemd. Are there any similar
examples I could study?

Many thanks,


More information about the systemd-devel mailing list