[systemd-devel] Running a script as FIRST script before shutdown

Mantas Mikulėnas grawity at gmail.com
Thu Sep 24 03:32:01 PDT 2015


On Thu, Sep 24, 2015, 09:40 Luca Bertoncello <L.Bertoncello at queo-group.com>
wrote:

> Hi Lennart,
>
> thank you for your answer!
>
> > There is no concept of "first" or "last" in systemd, since it's not
> clear what
> > that's supposed to mean if there are multiple, and what happens if some
> > operation results in activation?
>
> That's bad... :)
>
> > Hence, simply order your service against the services it requires. If
> you want
> > to just run some code when shutting down, make it a service with
> > Type=oneshot and RemainAfterExit=yes, give it an empty ExecStart=, but
> > specify ExecStop= to whatever it's supposed to do. Then order it *after*
> the
> > services that it shall be able to use, as the shutdown order in systemd
> is
> > always the inverse of the startup order, and what you specify via After=
> and
> > Before= specifies the startup order.
>
> Well, this is what I tried for more the three days... :(
> I know, that the script need at least vdsmd.service, vdsm-network.service
> and libvirtd.service.
> But it needs that the tmpfs-partition /run is mounted, too.
> I didn't found any service or target that mount/unmount /run. How can I
> specify it?
>

Well it's not a target nor a service – it's a mount. Therefore
"Requires=run.mount".

However /run will always be available on systemd systems, anyway. (That's
basically the whole point of /run…)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150924/012b69e3/attachment.html>


More information about the systemd-devel mailing list