[systemd-devel] How to start unit before everything else on shutdown

Nikolaus Rath Nikolaus at rath.org
Thu Nov 27 12:33:08 PST 2014


Mantas Mikulėnas <grawity at gmail.com> writes:
> On Wed, Nov 26, 2014 at 11:06 PM, Nikolaus Rath <Nikolaus at rath.org> wrote:
>
>> Hello,
>>
>> I'd like to start a unit on system shutdown and reboot, but do so
>> immediately after the "systemctl reboot" command is executed, before any
>> other units are terminated.
>
>> Is there a way to do that?
>>
>
> Not easily, I'd guess. (What would happen if two programs asked to be
> "absolutely first"?)

I'd say the same thing that currently happens if two programs specify to
be started before each other.

>> At first I thought that Before=shutdown.target might work, but thinking
>> about it, I think this just means that my unit will be started before
>> shutdown.target has been reached, but jobs to terminate other units may
>> be started before my unit. Is that correct?
>
> I think you'd need the unit to be After all regular units, have an empty
> ExecStart, and do its thing in ExecStop. So it'd be started after
> everything else, do nothing, and be stopped before everything else.

That sounded like a good idea at first, but I quickly hit the problem
that Andrei already saw: how do I start a unit after all other units?

Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«


More information about the systemd-devel mailing list