TIL: rtcwake / wakealarm

This may be old news to many of you, but today I learned you can have the computer's real time clock boot your machine at a specific time. The more proper way seems to be to use the 'rtcwake' command, but you can also do it by writing the timestamp of the startup time to /sys/class/rtc/rtc0/wakealarm Some more details of the /sys method - https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=309093&p=1849326&sid=ca7a14f7d160f929378be4691b1aed9e#p1849291 cheers, Stewart

That's cool. On Fri, Apr 9, 2021 at 10:23 PM Stewart C. Russell via talk <talk@gtalug.org> wrote:
This may be old news to many of you, but today I learned you can have the computer's real time clock boot your machine at a specific time. The more proper way seems to be to use the 'rtcwake' command, but you can also do it by writing the timestamp of the startup time to /sys/class/rtc/rtc0/wakealarm
Some more details of the /sys method - https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=309093&p=1849326&sid=ca7a14f7d160f929378be4691b1aed9e#p1849291
cheers,
Stewart --- Post to this mailing list talk@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk

On Fri, 9 Apr 2021 at 22:23, Stewart C. Russell via talk <talk@gtalug.org> wrote:
This may be old news to many of you, but today I learned you can have the computer's real time clock boot your machine at a specific time. The more proper way seems to be to use the 'rtcwake' command, but you can also do it by writing the timestamp of the startup time to /sys/class/rtc/rtc0/wakealarm
Some more details of the /sys method - https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=309093&p=1849326&sid=ca7a14f7d160f929378be4691b1aed9e#p1849291
This sounded pretty useful to me too, so I thought I'd try it out on an old netbook. I decided to use the netbook before messing about with power events on a computer I cared about. # rtcwake --date +5min --mode mem I chose "--mode mem" because this machine has often and successfully been suspended to RAM. The machine started flashing the power button orange as soon as I ran the command, which means "suspended-to-RAM." Five minutes later the power button turned steady blue again. But the screen remained off, and didn't wake on many keypresses. Including even on the power button. The machine was also not on the network, un-pingable. In the end, it was the five second press on the power button to kill it completely. This has left me reluctant to try this on any other machine. Presumably it would work fine on a Raspberry Pi as it came from a Pi forum and they're a fairly homogeneous form of hardware. But my one attempt doesn't recommend this ... -- Giles https://www.gilesorr.com/ gilesorr@gmail.com

On 2021-04-11 2:28 p.m., Giles Orr via talk wrote:
# rtcwake --date +5min --mode mem
I chose "--mode mem" because this machine has often and successfully been suspended to RAM.
Hi Giles - thanks for the report. I stayed away from using rtcwake, partly because of the report of it not working for the Raspberry Pi user. What I did - on my main Ubuntu laptop - at around 19:47 as root: echo 0 > /sys/class/rtc/rtc0/wakealarm echo `date +%s -d'19:50'` > /sys/class/rtc/rtc0/wakealarm I then used my normal shutdown procedure. I did not suspend in any way. At a couple of seconds before the requested 19:50 bootup time, my laptop powered up normally.
Presumably it would work fine on a Raspberry Pi as it came from a Pi forum and they're a fairly homogeneous form of hardware.
The hardware of the Raspberry Pi may be, but since none of them have an RTC built in, they have very different RTC options. Any chip you use you have to configure via I²C. Some of the chips that work as RTCs don't have alarm/wake-up capabilities. The DS3231 used in the original example is a bit of a step-up from most PC's RTCs. (There is a Raspberry Pi with a built-in RTC - the Raspberry Pi Pico micro controller board. It's rather hard to give it external battery power, though, so it's not very useful.) cheers, Stewart

| From: Stewart C. Russell via talk <talk@gtalug.org> | https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=309093&p=1849326&sid=ca7a14f7d160f929378be4691b1aed9e#p1849291 Intereresting. Thanks. I always thought that shutting down a Pi really left it on. That's one reason some people like Pi power supplies with a switch. To what extent is that true? How much power is saved? I delayed sending this message, hoping to add information about this but I'm just not getting to the experiments. Most PCs seem to have a firmware (BIOS) setting for when to wake up. I've never thought that useful since it required shutting the OS down and going into the firmware setup menu. The rtcwake(8) command was explored by Giles on a PC. It's available on my desktop. The manpage refers to nvram-wakeup, but I don't see that on my system (fedora). It seems to be part of debian. There are a lot of things under /sys/class/rtc/rtc0 on my desktop. I haven't searched for any documentation that might exist. On a related topic: Windows PCs seem to enter sleep mode when they haven't done anything for a certain amount of time. My Linux boxes don't, as far as I've noticed. Except for one Dell desktop box supplied with Ubuntu. It does this too. How does one configure conventional Linux to do this? (I could probably spelunk systemd on that Dell system to see what's going on but I fear entering a Labyrinth and never coming out.) Oh: systemd-hibernate-resume (8) - Resume from hibernation systemd-hibernate-resume-generator (8) - Unit generator for resume= kernel parameter systemd-hibernate-resume@.service (8) - Resume from hibernation systemd-hibernate.service (8) - System sleep state logic systemd-suspend-then-hibernate.service (8) - System sleep state logic systemd-sleep.conf (5) - Suspend and hibernation configuration file systemd-suspend-then-hibernate.service (8) - System sleep state logic systemd-suspend.service (8) - System sleep state logic I haven't read these yet or looked for an over-arching document.

On 2021-04-12 9:28 a.m., D. Hugh Redelmeier via talk wrote:
I always thought that shutting down a Pi really left it on. That's one reason some people like Pi power supplies with a switch. To what extent is that true?
It does: it just leaves the processor halted. So the other peripheral chips are still drawing power.
How much power is saved? I delayed sending this message, hoping to add information about this but I'm just not getting to the experiments.
Not much, but then, a Raspberry Pi doesn't draw much even running flat out. There are fancy Raspberry Pi add-ons that provide a proper logic-controlled shutdown and poweroff, but they typically cost about the same as a Raspberry Pi, or about two year's energy cost for running a Raspberry Pi 4B flat out. cheers, Stewart

On Fri, Apr 09, 2021 at 10:23:10PM -0400, Stewart C. Russell via talk wrote:
This may be old news to many of you, but today I learned you can have the computer's real time clock boot your machine at a specific time. The more proper way seems to be to use the 'rtcwake' command, but you can also do it by writing the timestamp of the startup time to /sys/class/rtc/rtc0/wakealarm
Some more details of the /sys method - https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=309093&p=1849326&sid=ca7a14f7d160f929378be4691b1aed9e#p1849291
Yes many PCs have had an option for the RTC to turn on the machine (could even configure it in the BIOS to always turn on the computer at a certain time for you). I have never used it (I don't tend to turn the computer off in the first place). No idea how many other platforms support it although I suspect not very many. I didn't think the raspberry pi even had a concept of software power control, which would make the RTC doing anything rather unlikely, although if it is just sleeping that would be a different story. Although suspend and sleep have often been rather hit or miss in my experience. -- Len Sorensen
participants (5)
-
D. Hugh Redelmeier
-
Giles Orr
-
lsorense@csclub.uwaterloo.ca
-
Stewart C. Russell
-
Warren McPherson