[systemd-devel] FC16 - how to get ExecStop= to be executed at shutdown?

Lennart Poettering lennart at poettering.net
Tue Dec 13 10:45:49 PST 2011


On Sun, 04.12.11 15:53, Josh Geisser (josh at gebaschtel.ch) wrote:

> Hi all
> 
> I succeeded with auto login and auto start of my Virtual Boxes, but could not get them to do a proper shutdown. 
> 
> Because of the nature of the VM processes I want to send them a proper ACPI shutdown button instead of terminating the process, which is done through my old rc-script. 
> 
> The VirtualBoxes process are started AFTER X11 is up, but must also be
> shutdown BEFORE the display-manager is exited.  

This is what happens with your configuration.
> 
> How do I configure this in the service file?
> 
> My /lib/systemd/system/vbox.service:
> 
> [Unit]
> Description=Virtual Box Machines
> After=vboxdrv.service network.target display-manager.service
> 
> [Service]
> Type=forking
> ExecStart=/home/vmuser/./rc.virtualboxes start | /usr/bin/logger
> ExecStop=/home/vmuser/./rc.virtualboxes stop | /usr/bin/logger

As Zbigniew already mentioned: the piping won't work and is redundant,
since we connect everything to syslog by default anyway. (Also, the /./
can be reduced to /).

it might make sense to enable debug logging to see what precisely
happens on shutdown and why things are not executed for you. For that
add "systemd.log_level=debug systemd.log_target=kmsg" to the kernel
cmdline.

If you need access to the kmsg log buffer at shutdown, consider dropping
a file like the following in /lib/systemd/system-shutdown, and marking
it +x:

#!/bin/sh
mount / -o rw,remount
dmesg > /shutdown.log
mount / -o ro,remount

This will store kmsg to /shutdown.log on shutdown.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list