I want raspi to (1) bootup, (2) do a task, (3) go into suspend mode for x amount of time, (4) wake up and do it all over again.

1 and 2 are easy: sudo crontab -e, which has just one line: @reboot /home/pi/boottasks.sh

boottasks.sh contains (and is made executable with chmod a+x boottasks.sh):


echo 'pi woke at ' ($date) >> boottasks.log

So far, I found out I can force reboot with sudo shutdown -r, and I can force hibernate with sudo shutdown -hP now

The problem is that raspi doesn't seem to obey what's in the crontab. That is, this line in the crontab: */30 * * * * sudo shutdown -r will not work if the last task list in boottasks.sh is sudo shutdown -hP now. In fact, that last bit is a good recipe for an endless loop that has pi rebooting all the time.

I can't believe what I want isnt't possible. I've seen the (somewhat straying discussion) here. Didn't answer my question.

And this, using rtcwake -m mem -s 180, runs into

rtcwake: open failed: /sys/class/rtc/rtc0/device/power/wakeup: No such file or directory
rtcwake: /dev/rtc0 not enabled for wakeup events

I'm new to Linux. But seasoned with computers. Any hints in the right direction would be much appreciated.

  • I do not think the Pi supports waking up from sleep or going into hibernation? Any way isn't rtcwake (real time clock wake) Do you know how many real-time clocks the Pi has? And why reboot it- Rebooting takes more power than idling. Recurring tasks can be handled using some simple python script or something running on a separate thread.
    – Piotr Kula
    Commented Oct 23, 2012 at 22:15
  • 1
    @ppumkin You're right, raspi doesn't have an rtc, right? Thanks, I hadn't made that connection yet. It does support hibernation, though. Watch what it does when you shutdown -hP now; power consumption drops significantly too. See also what AlesEames wrote on page 3 of this here thread link
    – RolfBly
    Commented Oct 24, 2012 at 18:47

4 Answers 4


rtcwake rely on hardware realtime clock which is missing in raspberry. You need to try (I haven't try personally, so it's my guess) some cheap rtc clock modules on ebay for raspberry, wire them and try to perform rtcwake. the reason why it works on other computers because they have these rtc hardware.


In this question you can find some interesting aspects of writing your own crontab.

My personal suggestion is to write your script as you'll do it normally, test & debug it, and then place the script inside the crontab with a line similar to:

*/30  *  *   *   *    /home/youruser/yourscriptdir/yourscriptname.sh >> /tmp/cron-temp.log 2>&1

However, you have to keep in mind that the script will be executed by the user cron with no knowledge of your PATH variable and, tipically, with different environment variables. You can watch them yourself with a line such as:

*/30  *  *   *   *    bash -c "export" >> /tmp/cron-temp.log 2>&1

Also don't forget to place the desired shebang line (such as #!/bin/bash or #!/bin/sh) at the head of your script, otherwise cron will call your script using sh.

If you want to have the sequence at boot, you could also choose to create an init script as mentioned in the post you linked.

Again, the cleanest approach is to have your own script inside your home folder and have an init script such as the following that calls your script:



case "$1" in
            echo "My first startup script!"

  restart|force-reload) exit 0 ;;
  *) echo "Usage: $0 {start|stop|restart|force-reload}" >&2; exit 1 ;;

You have to place the init script inside /etc/init.d and then you can add it to the boot sequence with:

update-rc.d name-of-the-init-script-in-etc-init.d defaults

I really don't know if the Pi supports the power management features that you're trying to use, but nevertheless, these two methods are worth knowing.


Conclusion: Pi can't hibernate for a given amount of time and then wake up by itself. A cheap alternative is an external time-switch. The scenario would then be:
1. Pi wakes up on the timer
2. performs tasks in crontab scheduled for boot time, including housekeeping and garbage collecting afterwards
3. shuts itself off (ie shutdown -h now)
4. timer removes power. You'd have to allow for sufficient time for 1 to 3 to complete, of course.

I find it rather disappointing that a device with so much horsepower can't be tamed, or at least not easily, to perform such a simple task.


Adding a RTC is possible with (e.g.) this OLimex Product. Some code is provided here.

Will rtcwake work with it ? You'll have to test it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.