[systemd-devel] Starting a unit on resume from suspend/hibernate

Lennart Poettering lennart at poettering.net
Thu Apr 2 11:42:08 PDT 2015


On Thu, 02.04.15 18:43, Dimitrios Apostolou (jimis at gmx.net) wrote:

> Hello list,
> 
> I'm having trouble to auto-activate a unit on resume, after suspend-to-ram
> or hibernation. The unit properly stops when suspending (because of
> Conflicts=sleep.target), but does not restart after resuming.

We do not really support that right now. Suspend/hibernate is
implemented as a single transaction, and you cannot stop a unit
and start it in the same transaction.

A hackish way to implement this is by using the suspend callout dir
/usr/lib/systemd/system-sleep/ (see systemd-suspend.service(8) for
details), and enqueue a stop and a start job from there, depending on
whether the hook is called before or after the
suspend/hibernation. But yeah, this is hackish.

Usually if one wants to do that one is just working around some
problems that are better solved in a different way.

Why precisely do you need this feature?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list