[systemd-devel] customized shutdown service needed

Lennart Poettering lennart at poettering.net
Mon Mar 5 06:04:46 PST 2012


On Wed, 29.02.12 22:12, Burkhard Kayser (kayser-b-2011 at t-online.de) wrote:

> 
> Hi Lennart,
> based on your recommendation I tried the following service.
> 
> [Unit]
> Description=my private startup service
> 
> Requires=local-fs.target syslog.service nfs.service
> After=local-fs.target syslog.service nfs.service
> 
> [Service]
> ExecStart=/etc/init.d/my_startup start
> ExecStop=/etc/init.d/my_startup stop
> Type=oneshot
> RemainAfterExit=yes
> TimeoutSec=600
> 
> [Install]
> WantedBy=multi-user.target


If this is a sysv init script then systemd will start this service
anyway, no need to write a unit file like the above. systemd provides a
certain level of compatibility with sysv scripts.

> This service is started at the very end of the boot sequence. But
> stopped too late during shutdown.

Too late? What do you mean by that?

> Feb 29 21:48:43 Linux1 logger: starting /etc/init.d/my_shutdown start
> (1) 1941 ...
> Feb 29 21:48:43 Linux1 logger: starting /etc/init.d/my_startup stop (1)
> 1937 ...

Hmm, the idea here is that a systemd service is started at bootup, and
stopped at shutdown. This output looks like you start and stop it at shutdown.

> Is there any similar replacement within systemd?

Well, for that you actually have to explain after what and before what
other services you want your service to be terminated.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list