Suspend and Wake PC at Certain Time – How to Schedule

schedulesleepsuspendwakeup

I want my PC to sleep at 04:58 and wake at 05:15, every day.

How do I do that?

Best Answer

You can do (at least half of) this with Gnome Schedule. (sudo apt-get install gnome-schedule) (NB: it gets put in your launcher as Scheduled Tasks, though typing gnome-schedule still brings it up.)

After launching it, "New" -> "Recurrent Task". Fill in the form as you see fit.

The command to hibernate is /usr/sbin/pm-hibernate (Suspend is /usr/sbin/pm-suspend)

In regards to waking up again, please see "How do I schedule waking up from hibernation?"


Alternately, you can install the "power management interface". (sudo apt-get install powermanagement-interface)

Then create a script like this:

#!/bin/bash
# This script puts the system under standby mode for x hours
usage() {
echo "usage: $0 <n-hours>"
echo "where <n-hours> is the number of hours to be on standby"
exit 0

}
if [ $# -ne 1 ]
then
usage
fi

PATH=$PATH:/usr/sbin
hours=$1
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo `date '+%s' -d "+ $hours hours"` > /sys/class/rtc/rtc0/wakealarm
## Edit the above line to get the exact length of hibernation you want
pmi action suspend

And schedule it in the root's crontab.

Source

Related Question