Open Flowdalic opened 1 year ago
Interesting, I didn't even know such a feature exists. What is your use case for this?
We schedule automatic reboots based reboot-required.pkgs and needrestart information. If the systems suspend while a scheduled reboot is pending, and awakes after the time of the scheduled reboot, the scheduled reboot fails. Waking the system up, briefly before the scheduled reboot, causes the system to reboot.
I just wanted to look at this issue again. What command do you actually use to schedule a reboot?
Btw, looking at this StackExchnage question, it seems that for the moment you should be able to create a simple script for the Comannd wakeup check to workaround the lack of the feature right now.
What command do you actually use to schedule a reboot? For example
$ shutdown --reboot +02:00 "Scheduled reboot for maintenance"
Btw, looking at this StackExchnage question, it seems that for the moment you should be able to create a simple script for the Comannd wakeup check to workaround the lack of the feature right now.
Yes we have something like that in place
#!/usr/bin/env bash
set -eou pipefail
# Although this file is called wakeup-before-scheduled-reboot we
# actually check for the next scheduled reboot *or* shutdown. But this
# does not really matter, as we want to wakeup in both cases and we
# only schedule reboots.
SCHEDULED_SHUTDOWN_INFO=$(busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager ScheduledShutdown)
declare -i SCHEDULED_SHUTDOWN_SECS
SCHEDULED_SHUTDOWN_SECS=$(echo "${SCHEDULED_SHUTDOWN_INFO}" | cut -d ' ' -f 3)
if [[ ${SCHEDULED_SHUTDOWN_SECS} -eq 0 ]]; then
# Output the empty string to make autosuspend happy.
echo ""
exit
fi
BEFORE_SCHEDULED_SHUTDOWN_SECS=$(( SCHEDULED_SHUTDOWN_SECS - 180 ))
echo "${BEFORE_SCHEDULED_SHUTDOWN_SECS}"
which is added as script to autosuspend's configuration
[wakeup.BeforeScheduledReboot]
enabled = true
class = Command
command = /etc/autosuspend/wakeup-before-scheduled-reboot
Fun thing about the shutdown
command: that is provided by the systemd compatibility layer for sysv. However, I couldn't find any way to achieve the same behavior without this compatibility command.
Fun thing about the
shutdown
command: that is provided by the systemd compatibility layer for sysv. However, I couldn't find any way to achieve the same behavior without this compatibility command.
Probably because the functionality already exists in that said program. I assume it is meant as drop-in replacement, not as something that will ever disappear. That said, I wouldn't be surprised if this where possible using some dbus API.
Please consider adding a new wakeup check for systemd scheduled reboots. In case there is a scheduled shutdown or reboot pending, the wakeup check should schedule a wakeup briefly, say 3-5 minutes, before the scheduled shutdown or reboot. One can retrieve information about scheduled shutdowns or reboots via e.g.,