is it possible to wake up a Linux device at a specific time
I run Debian on an embedded board. I would like to suspend or hibernate the board say at 10 pm and wake it up at 7 am. There is no problem to suspend/hibernate the board by pmi action suspend
/hibernate
. But, I wonder if it is possible to schedule the board to wake up at a specific time (maybe by using cron or something else?). If it is the case, could you please explain the all necessary steps that how I can do it?
Please note that, it is possible to wake up an embedded board by using an external interrupt signal or building a simple circuit with a MCU like PIC, timer and relay to set when to wake up the board. But is is not what I am asking for. I would like to learn if there is any method on Linux to perform the wake up operation. The board has a WiFi connection and not possible to attach another cable apart from the power cable (please do not write about wake-on-lan).
Consider what you are asking for. You want a single device, which is powered off, to execute some code at some specific time which turns it on. What would execute that code? What would make the device execute that code?
Depending on how deeply asleep the device is, it might be possible by configuring the BIOS to power on the device at a specific time, if the BIOS supports such a feature. You'd be fiddling directly with bits in CMOS memory on power-down and hoping that you aren't corrupting anything, but in principle it should be doable, and if you don't need e.g. resilience in the case of a BIOS upgrade, it might even be practical. That still does depend on the device not being fully powered off, however; something has to be monitoring the system real-time clock and executing a power-on sequence when it hits a preselected value. Same with techniques such as Wake on LAN, Wake on Ring etc., which all depend on something triggering the power-on event. (Do I get a downvote now for writing about Wake on LAN despite you asking answerers not to...?)
More to the point, what is triggered in ATX (even by a power button press) is a transition from one power state to another. The only way to fully shut down an ATX system is to turn off the power supply using the switch at the PSU, or unplugging the power cord. This in contrast to AT PSUs, which actually fully powered down when you turned the computer off because the power switch was in line with the AC power cord in the same way ATX PSU power switches (not the computer's power button) are. It doesn't really make any difference though, because whether the system is fully powered down or simply running some kind of loop which waits for the system clock to hit a specific value, there is nothing running the operating system, and the CPU, even if it is powered on (which is an implementation detail of the motherboard and BIOS; they might be using a supplemental, low-powered CPU just for simple tasks like that), won't be running your installed code, so there's no Linux anywhere in sight as far as the CPU is concerned, much less anything like cron.
Bottom line; I would be exceptionally surprised if what you are asking is doable directly through Linux, although it might be possible by looking at the bigger picture of the surrounding hardware and firmware. The safest bet almost certainly is precisely that external trigger, programmed on shutdown to trigger a power-on sequence after a given interval or at a given time (if it has an independent RTC).
Just for anyone else who is searching for this, look at the interface for the RTC. On my current system, writing a date in the future to /sys/class/rtc/rtc0/wakealarm
will make the system wake up in the future. For example:
# wake up the system in 3 minutes
sh -c "echo `date '+%s' -d '+ 3 minutes'` > /sys/class/rtc/rtc0/wakealarm"
Change the + 3 minutes
to tomorrow 0700
is close to what you want, unless you run the command after midnight...
I found this on linux.com.