<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Droid Sans'; font-size:10pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">The key thing is the TimeoutSec.  without that, systemd just gives up after a few seconds and SIGKILLs everything.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; ">&nbsp;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br />On Tuesday, February 28, 2012 20:37:14 Burkhard Kayser wrote:<br /></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Hi<br />I tried as well the following configuration. My script shall be started before ANY other service is shut down.<br />Stopping a virtual machine is only one example. Synchronizing data into a truecrypt container another.<br /><br /><br /></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">[Unit]<br />Description=my shutdown service<br /><br />Before=shutdown.service halt.service shutdown.target umount.target<br />DefaultDependencies=no<br /><br />[Service]<br />ExecStart=/etc/init.d/my_shutdown start<br />Type=oneshot<br />RemainAfterExit=true<br />TimeoutSec=600<br /><br />[Install]<br />WantedBy=shutdown.target<br /><br /><br /><br />My script is started almost at the end of the shutdown sequence. See var/log/messages below.<br /><br /><br /></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Feb 28 20:26:54 Linux1 systemd[1]: alsa-store.service: main process exited, code=exited, status=19<br />Feb 28 20:26:54 Linux1 systemd[1]: Unit alsa-store.service entered failed state.<br />Feb 28 20:26:54 Linux1 sshd[2233]: Exiting on signal 15<br />Feb 28 20:26:54 Linux1 alsactl[2391]: /usr/sbin/alsactl: save_state:1519: No soundcards found...<br />Feb 28 20:26:54 Linux1 haveged: haveged stopping due to signal 15<br />Feb 28 20:26:54 Linux1 umount[2374]: umount: /var/lib/nfs/rpc_pipefs: device is busy.<br />Feb 28 20:26:54 Linux1 umount[2374]: (In some cases useful info about processes that use<br />Feb 28 20:26:54 Linux1 avahi-daemon[652]: avahi-daemon 0.6.30 exiting.<br />Feb 28 20:26:54 Linux1 umount[2374]: the device is found by lsof(8) or fuser(1))<br />Feb 28 20:26:54 Linux1 systemd[1]: var-lib-nfs-rpc_pipefs.mount mount process exited, code=exited status=1<br />Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-etc.mount entered failed state.<br />Feb 28 20:26:55 Linux1 systemd[1]: Unit srv-mywiki.mount entered failed state.<br />Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-tmp.mount entered failed state.<br />Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-Download.mount entered failed state.<br />Feb 28 20:26:55 Linux1 logger: starting /etc/init.d/my_shutdown start (1) 2392 ...<br />Feb 28 20:26:55 Linux1 my_shutdown[2392]: + case &quot;$1&quot; in<br />Feb 28 20:26:55 Linux1 my_shutdown[2392]: + echo 'Tue Feb 28 20:26:55 CET 2012: /etc/init.d/my_shutdown start'<br />Feb 28 20:26:55 Linux1 my_shutdown[2392]: ++ date<br />Feb 28 20:26:55 Linux1 my_shutdown[2392]: + D='Tue Feb 28 20:26:55 CET 2012'<br />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'<br />Feb 28 20:26:55 Linux1 my_shutdown[2392]: + logger '/etc/init.d/my_shutdown done'<br />Feb 28 20:26:55 Linux1 logger: /etc/init.d/my_shutdown done<br />Feb 28 20:26:55 Linux1 sshd[1780]: Received signal 15; terminating.<br />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<br />Feb 28 20:26:55 Linux1 ntpd[1801]: ntpd exiting on signal 15<br />Feb 28 20:26:55 Linux1 kernel: Kernel logging (proc) stopped.<br />Feb 28 20:26:55 Linux1 rsyslogd: [origin software=&quot;rsyslogd&quot; swVersion=&quot;5.8.5&quot; x-pid=&quot;623&quot; x-info=<a href="http://www.rsyslog.com"><span style=" text-decoration: underline; color:#0057ae;">&quot;http://www.rsyslog.com&quot;</span></a>] exiting on signal 15.<br /><br /><br /><br />On 27/02/12 01:49, Eduardo Tongson wrote: </p>
<pre style=" margin-top:12px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">On Sun, Feb 26, 2012 at 4:24 PM, Burkhard Kayser</span></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a href="mailto:kayser-b-2011@t-online.de"><span style=" font-family:'Courier New,courier'; text-decoration: underline; color:#0057ae;">&lt;kayser-b-2011@t-online.de&gt;</span></a><span style=" font-family:'Courier New,courier';"> wrote:</span> </pre>
<pre style=" margin-top:12px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Hello,</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">I do need a customized shutdown service which performs some clean up tasks,</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">e.g. stopping virtual machines,  before the shutdown service of systemd</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">actually starts.</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">The shutdown of the system shall be delayed until my script is terminated.</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">I could not find a suitable configuration. The &quot;templates&quot; in /lib/systemd</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">did not help.</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">I've an OpenSuSE 12.1 system with latest patches installed.</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Here is my configuration:</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">[Unit]</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Description=my shutdown service</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Before=shutdown.service halt.service</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">DefaultDependencies=no</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">[Service]</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">ExecStart=/etc/init.d/my_shutdown start</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Type=oneshot</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">RemainAfterExit=true</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">[Install]</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">WantedBy=shutdown.target</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Can please somebody point me to the right configuration?</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Thanks for your help.</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Regards</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Burkhard</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">_______________________________________________</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">systemd-devel mailing list</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a href="mailto:systemd-devel@lists.freedesktop.org"><span style=" font-family:'Courier New,courier'; text-decoration: underline; color:#0057ae;">systemd-devel@lists.freedesktop.org</span></a></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel"><span style=" font-family:'Courier New,courier'; text-decoration: underline; color:#0057ae;">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</span></a></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:120px; margin-right:120px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"> </pre>
<pre style=" margin-top:12px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">This works consistently in my setup:</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">[Unit]</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">DefaultDependencies=no</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Before=shutdown.target</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">[Service]</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Type=oneshot</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">ExecStart=script</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">_______________________________________________</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">systemd-devel mailing list</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a href="mailto:systemd-devel@lists.freedesktop.org"><span style=" font-family:'Courier New,courier'; text-decoration: underline; color:#0057ae;">systemd-devel@lists.freedesktop.org</span></a></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:80px; margin-right:80px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel"><span style=" font-family:'Courier New,courier'; text-decoration: underline; color:#0057ae;">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</span></a> <br /></pre>
<pre style=" margin-top:12px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">-- </span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Burkhard Kayser</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Im Stiegel 9</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">D-71549 Auenwald</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Phone:  +49 7191 58288 </span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Mobile: +49 160 9136 8972</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">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.</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"><br /></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:40px; margin-right:40px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">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.</span> </pre>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /><br /></p></body></html>