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

Andrei Borzenkov arvidjaar at gmail.com
Thu Nov 27 07:41:15 PST 2014


В Thu, 27 Nov 2014 14:17:49 +0200
Mantas Mikulėnas <grawity at gmail.com> пишет:

> 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.
> >
> 
> Out of curiosity, what does your unit do? Is there a specific reason for it
> to be absolutely first?
> 
> 
> > Is there a way to do that?
> >
> 
> Not easily, I'd guess. (What would happen if two programs asked to be
> "absolutely first"?)
> 
> 
> > 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,

And how do you do *that*? rc-local has been requested by users for years
and answer was - you do not need it. 
>                                                            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.
> 



More information about the systemd-devel mailing list