Can you make a linux system halt and boot my Raspberry-pi at certain times?
You can suspend or hibernate your system and then automatically wake it up with rtcwake
command. For example to suspend (to ram) and resume in 60 seconds do
rtcwake -s 60 -m mem
To hibernate (suspend to disk) in one hour from now and resume in two hours:
sleep 3600; rtcwake -s 3600 -m disk
You can also wakeup the system at given time with -t
option which takes seconds since 1970 as an argument. Run man rtcwake
for more info.
You should be able to do this with a mains timer between the mains outlet and the power supply.
Shut down the Raspberry at 4 A.M using a cron job, then set the timer to cut the mains a bit later and to restore power at 5 A.M.
You can get it to turn off whenever you like with halt
or shutdown now
or whatever you prefer; schedule that with cron
or a custom sleeping background process.
In addition to the real time wakeup implemented by normal PC hardware (which the pi isn't) and usable via rtcwake
, there is wake-on-LAN.
Unfortunately, neither of those will work on the raspberry pi, since you can't:
- Suspend to RAM.
- Kill or reset the power, except by pulling the plug.
- Suspend to storage, except (possibly) by doing some modifications to the OS configuration (as is, raspbian uses a compressed ramdisk for swap) -- and even then the bootloader will not give you the option to bypass, either.
The pi hardware does not have any "power management" features at all beyond reboot. If it is plugged in, it is on, and it remains on after the system halts.