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

Mantas Mikulėnas grawity at gmail.com
Wed Sep 23 09:48:13 PDT 2015


On Wed, Sep 23, 2015 at 5:20 PM, Luca Bertoncello <
L.Bertoncello at queo-group.com> wrote:

> Hi list!
>
> I'm new here and I hope, I'm in topic... I don't want to develop system,
> but I didn't found a "system-user"-ML...
>

Yeah, systemd-devel is still also the tech support list.


> So, to my problem:
> I need a possibility to call a script on shutdown/reboot/halt (I use
> CentOS 7). This **MUST** be the first one be called, since it needs many
> other service to be running...
>

Almost always, being "first" is a made up requirement. The actually
important part here is "it needs many other services" – and you probably
know /which/ specific services it needs, so you can declare them as
dependencies in your unit. *(Sometimes takes some trial and error
though...)*

In systemd, the shutdown order is generally inverse of the boot order – if
a unit has "After=X", it will be started after X, but stopped before X. So
your unit should have a Requires= (or Wants=) plus an After= for every
service it actually needs.

Also – the unit seems more like a Type=oneshot, not a Type=simple.

-- 
Mantas Mikulėnas <grawity at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150923/5b73308d/attachment.html>


More information about the systemd-devel mailing list