-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature: Don't suspend if cron/at jobs about to run & resume when cron/at jobs due to run #96
Comments
Interesting idea. This would basically result in an activity check that determines whether a cron job will become active soon. Is it really cron that you need or systemd timers? |
In reality probably both now that I think about it. |
What kind of cron job / systemd timer do you think about. Because timers - depending on the configuration - are executed also after waking up again. So I don't see why for an unattended update the system has to stay awake if things continue after waking up again. This feature would probably only be useful for things like recordings that are time critical? Or which exact use cases do you have? For scheduled tasks on things like tvheadend, the respective wake up check should be configured because a known wake up point will already prevent suspending. |
and another side note: you can also let systemd timers or cron jobs program the wakeup point of the system. |
Yeh I had a look at doing that - it means you've got to change the cron/at tasks submitted and change the systemd files which is not good because they get updated as part of standard package updates. |
I'll think about this feature. But time is currently quite limited. Might take a moment. |
Interesting enough, I was just thinking about opening a feature request for the SystemD-timer aspect, so it is nice to see this discussed :) For Cron, I imagine this to be an involved implementation, as the implementation would either be daemon-dependent or require a reimplementation of cron's configuration format (including all the different cron.daily etc.pp. conventions). Another question would be how one references individual cron-jobs. It's hardly desireable to wake up for all cron jobs (e.g. rebuilding man db)... At least for SystemD timers, both problems should be solveable... Identifyability by canonical name is given, and an API exists to query the next execution instance for a given timer. What is nice is that this is nearly expressable with wakeup checks already (It's a variant of the solutions in the stackoverflowlink that @neeto33 has provided above): [wakeup.RsnapshotMonthly]
class = Command
enabled = true
command = date -d "$$(LANG=C LC_TIME=C systemctl show rsnapshot-monthly.timer --property=NextElapseUSecRealtime --value | cut -d' ' -f 2-)" +%s And it nearly works: If freshly configured, the box will wake up ONCE at the timers start time, but the PC will not be woken up again when autosuspend has put my NAS to sleep again after the rsnapshot run has finished. My guess is: while the timers SystemD-Unit is active, the above command reports the current activation's time, so a date in the past. And so there might be an race between "reexecute the wakeup scheduler" and "put the box to sleep". But as said: this is just a guess, I've not yet had time to look into the code... But it seems plausible, as, when I wake up my NAS manually between two timer activations, the wakup-check fires again. |
Just to be sure regarding the potential race: did you also enable the |
Ah, thanks for the pointer. Yes, it is enabled, but the logs are helpful. I definitely should have checked the suspend-hook's logs earlier, and not just those of the main unit :)
Apparently, my NAS is at least one Intel-generation short of having a wake-alarm that works more than one day into the future:
So it seems that the above works with systemd-timers, just not on my system :) @languitar: Thanks for the help (and the software in general, it's great) |
What a weird restriction. You probably have to clamp this to get intermediate wakeups for rescheduling until the actual event. |
Well, apparently acpi declares wakeups for intervals longer than one day as optional, guarded by the "DAY_ALRM" field within the FADT part of ACPI. What I've read, it actually is not tooo uncommon with older chip(sets), so approx. pre-sandybridge ones to miss it. So yeah, as I did not want to clamp, I've written a small wake-on-lan--scheduler that can be run on my openwrt-router and accepts wakeup-scheduling requests from my NAS, I'll have to see how well this works out. But that leaves the scope of this issue, sorry for the small hijacking, and thanks once more for your help! |
Using wake on lan sounds like a good solution then if it's not too brittle. You have changed |
Yep, that is pretty much it. Currently, it's [general]
wakeup_cmd = curl --data "mac=XX:XX:XX:XX:XX:XX" --data "timestamp={timestamp:.0f}" http://routerhostname.lan/cgi-bin/disorganizer-cgi but in the long term I'm toying around with the idea of using a wrapper script that first tries to write to rtc, catch the invalid argument error if necessary and only then requesting wake-on-lan wakeups. And probably some error handling around curl (such as actually clamping if something goes wrong there) might be nice as well :) |
Nice, if you got anything running in that direction it would be nice to add this to the documentation as an FAQ entry |
This will eventually resolve something similar to #96 for systemd timers.
This will eventually resolve something similar to #96 for systemd timers.
This will eventually resolve something similar to #96 for systemd timers.
This will eventually resolve something similar to #96 for systemd timers.
Two parts to this feature
This will need a configurable parameter on how many seconds in future the cron/at task must be so that suspend will happen
This will need a configurable parameter on how many second to wake up before the cron/at task is to be run
The text was updated successfully, but these errors were encountered: