[systemd-devel] Trying to turn off a UPS with home-made service unit

Lennart Poettering lennart at poettering.net
Wed Sep 11 10:45:48 PDT 2013


On Sat, 10.08.13 17:02, Roger Price (roger at rogerprice.org) wrote:

> I am new to systemd and I am trying to power off a UPS unit using a
> home-made service unit
> /lib/systemd/system/ups-delayed-shutdown.service running on openSUSE
> 12.3.

So, it's a really bad idea to turn off UPS from userspace, simply
because you will race against the kernel's fs sync() code, and you
never know what will finish first: your UPS shutdown timeout or your fs
sync(). Doing this from userspace is hence racy.

If you want to use a hack like this then at least do it via the
/usr/lib/systemd/system-shutdown/ drop-in directory which is called very
late during shutdown. It will shorten the race window, but not erase it,
since the kernel will flush various buffers only after the reboot()
system call is invoked.

See systemd-shutdown(8) for details.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list