[systemd-devel] Starting a service on shutdown
Umut Tezduyar
umut at tezduyar.com
Mon Jan 21 04:38:53 PST 2013
Hi
How do I start a service on shutdown that will start and finish before any
of the mount points being unmounted?
As it is explained here (
http://lists.freedesktop.org/archives/systemd-devel/2012-November/007558.html)
the shutdown order is the reverse of startup order though it is not clear
what is happening when a service that is not in the startup sequence is
being started. Following is a sample unit file I have been working on.
[Unit]
Description=Taking Long Time
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/sleep 60
[Install]
WantedBy=shutdown.target
Before=shutdown.target ensures that shutdown.target is not reached before
the service is finished since it's type is "oneshot". But if I add
"Before=umount.target" or "Before=basic.target" to the service file, the
requested shutdown order is not obeyed.
Output snipped:
[OK] Stopped target Local File Systems
Unmounting /usr/local...
Unmounting /lib/persistent...
Starting Taking Long Time
[OK] Unmounted /usr/local
[OK] Unmounted /lib/persistent
What am I trying to achieve:
I would like to start a service on shutdown/restart. This service accesses
(read/write) to the file systems and for that reason I don't want any of
the file systems unmounted by systemd before the service completes.
Thank you,
Umut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130121/abe50cf7/attachment.html>
More information about the systemd-devel
mailing list