[systemd-devel] customized shutdown service needed

Manuel Amador rudd-o at rudd-o.com
Wed Feb 29 00:18:56 PST 2012


The key thing is the TimeoutSec.  without that, systemd just gives up after a 
few seconds and SIGKILLs everything.


On Tuesday, February 28, 2012 20:37:14 Burkhard Kayser wrote:

Hi
I tried as well the following configuration. My script shall be started before 
ANY other service is shut down.
Stopping a virtual machine is only one example. Synchronizing data into a 
truecrypt container another.



[Unit]
Description=my shutdown service

Before=shutdown.service halt.service shutdown.target umount.target
DefaultDependencies=no

[Service]
ExecStart=/etc/init.d/my_shutdown start
Type=oneshot
RemainAfterExit=true
TimeoutSec=600

[Install]
WantedBy=shutdown.target



My script is started almost at the end of the shutdown sequence. See 
var/log/messages below.



Feb 28 20:26:54 Linux1 systemd[1]: alsa-store.service: main process exited, 
code=exited, status=19
Feb 28 20:26:54 Linux1 systemd[1]: Unit alsa-store.service entered failed 
state.
Feb 28 20:26:54 Linux1 sshd[2233]: Exiting on signal 15
Feb 28 20:26:54 Linux1 alsactl[2391]: /usr/sbin/alsactl: save_state:1519: No 
soundcards found...
Feb 28 20:26:54 Linux1 haveged: haveged stopping due to signal 15
Feb 28 20:26:54 Linux1 umount[2374]: umount: /var/lib/nfs/rpc_pipefs: device 
is busy.
Feb 28 20:26:54 Linux1 umount[2374]: (In some cases useful info about 
processes that use
Feb 28 20:26:54 Linux1 avahi-daemon[652]: avahi-daemon 0.6.30 exiting.
Feb 28 20:26:54 Linux1 umount[2374]: the device is found by lsof(8) or 
fuser(1))
Feb 28 20:26:54 Linux1 systemd[1]: var-lib-nfs-rpc_pipefs.mount mount process 
exited, code=exited status=1
Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-etc.mount entered failed 
state.
Feb 28 20:26:55 Linux1 systemd[1]: Unit srv-mywiki.mount entered failed state.
Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-tmp.mount entered failed 
state.
Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-Download.mount entered 
failed state.
Feb 28 20:26:55 Linux1 logger: starting /etc/init.d/my_shutdown start (1) 2392 
...
Feb 28 20:26:55 Linux1 my_shutdown[2392]: + case "$1" in
Feb 28 20:26:55 Linux1 my_shutdown[2392]: + echo 'Tue Feb 28 20:26:55 CET 
2012: /etc/init.d/my_shutdown start'
Feb 28 20:26:55 Linux1 my_shutdown[2392]: ++ date
Feb 28 20:26:55 Linux1 my_shutdown[2392]: + D='Tue Feb 28 20:26:55 CET 2012'
Feb 28 20:26:55 Linux1 my_shutdown[2392]: + echo 'Tue Feb 28 20:26:55 CET 
2012: /etc/init.d/my_shutdown start done'
Feb 28 20:26:55 Linux1 my_shutdown[2392]: + logger '/etc/init.d/my_shutdown 
done'
Feb 28 20:26:55 Linux1 logger: /etc/init.d/my_shutdown done
Feb 28 20:26:55 Linux1 sshd[1780]: Received signal 15; terminating.
Feb 28 20:26:55 Linux1 httpd2[2395]: httpd2: Could not reliably determine the 
server's fully qualified domain name, using 192.168.1.27 for ServerName
Feb 28 20:26:55 Linux1 ntpd[1801]: ntpd exiting on signal 15
Feb 28 20:26:55 Linux1 kernel: Kernel logging (proc) stopped.
Feb 28 20:26:55 Linux1 rsyslogd: [origin software="rsyslogd" swVersion="5.8.5" 
x-pid="623" x-info="http://www.rsyslog.com"] exiting on signal 15.



On 27/02/12 01:49, Eduardo Tongson wrote: 
On Sun, Feb 26, 2012 at 4:24 PM, Burkhard Kayser
<kayser-b-2011 at t-online.de> wrote: 
Hello,
I do need a customized shutdown service which performs some clean up tasks,
e.g. stopping virtual machines,  before the shutdown service of systemd
actually starts.
The shutdown of the system shall be delayed until my script is terminated.

I could not find a suitable configuration. The "templates" in /lib/systemd
did not help.

I've an OpenSuSE 12.1 system with latest patches installed.

Here is my configuration:

[Unit]
Description=my shutdown service

Before=shutdown.service halt.service
DefaultDependencies=no

[Service]
ExecStart=/etc/init.d/my_shutdown start
Type=oneshot
RemainAfterExit=true

[Install]
WantedBy=shutdown.target


Can please somebody point me to the right configuration?

Thanks for your help.

Regards
Burkhard

_______________________________________________
systemd-devel mailing list
systemd-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel
 
This works consistently in my setup:

[Unit]
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=script
_______________________________________________
systemd-devel mailing list
systemd-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel 

-- 
Burkhard Kayser
Im Stiegel 9
D-71549 Auenwald

Phone:  +49 7191 58288 
Mobile: +49 160 9136 8972

This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify me by replying to this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interception, unauthorized amendment, tampering and viruses, and I only send and receive emails on the basis that I am not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof. 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20120229/c7fe13be/attachment-0001.html>


More information about the systemd-devel mailing list