I'm attempting to add functionality to a systemd service ([email protected]) using an override file. The trouble I'm having is that I need the new functionality to always run "inside" the old functionality, i.e., after the ExecStart= and before the ExecStop= of the original service (since it mounts a filesystem on the directory created by the old functionality, then unmounts it before that directory is deleted).

The former is easy enough, since I can use ExecStartPost= to ensure the proper ordering. But there isn't an ExecStopPre=, and if I just use ExecStop=, there's no guarantee of ordering, and in practice it turns out wrong.

Are there any workarounds for this?

  • (I have considered the idea of replacing the unit entirely by placing a modified file in /etc/systemd/system, but I'd prefer not to take up the local customization path in a distributable package.)
    – Cerebrate
    Commented Sep 6, 2022 at 17:50

1 Answer 1


Are there any workarounds for this?

If you need explicit ordering, you can replace the existing ExecStop functionality in the override. So e.g., if the original unit file had:


In your drop-in override, you could have:


The empty ExecStop= clears out any existing entries.

Alternately, instead of using ExecStop, it may be possible to implement your logic as separate units using appropriate dependencies (Requires/Before/After/etc).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .