[systemd-devel] Shutdown a specific service in systemd shutdown

Martin Pitt martin.pitt at ubuntu.com
Thu May 19 08:57:21 UTC 2016


Hello Bao,

Bao Nguyen [2016-05-19 15:52 +0700]:
> When the system is shutdown, systemd will terminate all services in
> parallel manner, could you let me know if there is any ways to tell systemd
> to shutdown a specific service first, then shutdown all remaining services?

The concept of "first"/"last" has no well-defined meaning in any
non-serial init systems (not even SysV init with insserv, only with
classic SysV init with manually set priorities). I've heard requests
like "but this needs to be started as the last thing" a lot in the
recent years, and there's no way all the services can simultaneously
be "last" :-)

You should put sufficient After= properties into your service, so that
it gets started after and stopped before the ones you specify. See
man systemd.unit for details.

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


More information about the systemd-devel mailing list