[systemd-devel] Script in /usr/lib/systemd/system-shutdown not executed on init 6

Lennart Poettering lennart at poettering.net
Wed Nov 23 23:22:32 UTC 2016


On Wed, 23.11.16 13:42, Benoit SCHMID (Benoit.Schmid at unige.ch) wrote:

> Hello,
> 
> On 11/23/2016 11:55 AM, Lennart Poettering wrote:
> > The scripts dropped there are executed very late during the shutdown
> > process at a time where all processes have already been killed and all
> > mount points have been unmounted or at least remounted
> > read-only.
> 
> Is there an easy way to create a systemd service that would be stopped
> very early
> at the shutdown and would avoid the other services stop command to be
> executed.

In systemd there's no concept of "very early". There's just a concept
of "stop unit A before unit B", but you have to configure A and B
explicitly, there's no "catchall" unit logic available.

As I understand you, you want to define a system service that is
ordered After= all user logins, so that (following the rule that on
systemd the shutdown order is the inverse of the startup order) the
service is stopped before the sessions are closed. The idea of such a
thing doesn't make too much sense to me though, as it's really not
clear what this should mean. A user logging out manually right before
the system is shutdown and a user forcibly being logged out due to the
system going down would have a very different semantics in this case
but I doubt it should.

But regardless of this: login session unit names cannot really be
guessed in advance, hence you you cannot define the right dependencies
a priori.

It appears to me that you are trying to press semantics into the
systemd dependency tree that really shouldn't be pressed into it. I am
pretty sure that there's a better way to package your service into
systemd units than this.

In general, while systemd provides a large degree of SysV compat, in
the end we aren't SysV and thus we do not provide 100%. In cases like
this this becomes visible.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list