You are not logged in.

#1 2013-09-15 07:27:05

Ovion
Member
Registered: 2013-02-24
Posts: 78

[solved] systemd-target for wakeup

Hi guys,

I want a servicefile being executed on every wakeup, bootup as well as recovering from sleep.
The solution I'm thinking of at the moment consists of three servicefiles:
One starting my job, bound to bootup.target or something like this, another one starting the same job bound to sleep.target, a third one that is ment to enable both files when getting enabled itself. This is because I want one servicefile belonging to this one job.

But as this is ugly I would like to have one servicefile. I can bind it easily to sleep.target and bootup.target simply using "WantedBy=" twice, but as the job needs to be executed on *wakeup*, I need to use "After=sleep.target", but I'm afraid that would interfere with activation on bootup, leading to the job being not executed on bootup as bootup is no wakup from sleep and thus sleep.target is not triggered.

Any ideas concerning this? I'd appreciate it. smile

Last edited by Ovion (2013-09-15 16:53:37)

Offline

#2 2013-09-15 13:19:40

R00KIE
Forum Moderator
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 3,026

Re: [solved] systemd-target for wakeup

I'm using the following for a service I use to set hdd apm after boot/suspend/hibernate and it has been working fine

[Unit]
Description=Set the Advanced Power Management level of a chosen Hard Disk
After=basic.target
After=suspend.target
After=hibernate.target

[Service]
Type=oneshot
ExecStart=your program or script goes here

[Install]
WantedBy=basic.target
WantedBy=suspend.target
WantedBy=hibernate.target

R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#3 2013-09-15 15:48:34

Ovion
Member
Registered: 2013-02-24
Posts: 78

Re: [solved] systemd-target for wakeup

It does work? Interesting, thanks, then I'll go this way!

Offline

#4 2013-09-15 16:34:56

Ovion
Member
Registered: 2013-02-24
Posts: 78

Re: [solved] systemd-target for wakeup

By the way:
Do After= and Before= mean After-if-this-service-or-target-is-pulled-in-othewise-this-option-is-without-effect= and Before= corresponding?

Offline

#5 2013-09-15 16:40:42

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [solved] systemd-target for wakeup

Ovion wrote:

By the way:
Do After= and Before= mean After-if-this-service-or-target-is-pulled-in-othewise-this-option-is-without-effect= and Before= corresponding?

yes, After/Before have no effect if the listed units are not part of the start process.

Offline

#6 2013-09-15 16:53:14

Ovion
Member
Registered: 2013-02-24
Posts: 78

Re: [solved] systemd-target for wakeup

I see, that vanishes my worries in the first post. Thanks!

Last edited by Ovion (2013-09-15 16:53:23)

Offline

Board footer

Powered by FluxBB