Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

How do I do that?

share|improve this question
add comment

3 Answers 3

up vote 7 down vote accepted

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

share|improve this answer
add comment

              How to Make Your Linux PC Wake From Sleep Automatically

Want to put your Linux PC into sleep or hibernate mode and have it automatically wake at a specific time? You can easily do this with the rtcwake command, included by default with most Linux systems.

This can be useful if you want your computer to do something at a specific time, but don’t want it running 24/7. For example, you could put your computer to sleep at night and have it wake up before you do to perform some downloads.

Using rtcwake

T he rtcwake command requires root permissions, so it must be run with sudo on Ubuntu and other Ubuntu-derived distributions. On Linux distributions that don’t use sudo, you’ll have to log in as root with the su command first.

Here’s the basic syntax of the command:

sudo rtcwake -m [type of suspend] -s [number of seconds]

For example, the following command suspends your system to disk (hibernates it) and wakes it up 60 seconds later:

sudo rtcwake -m disk -s 60

Types of Suspend

The -m switch accepts the following types of suspend:

standby – Standby offers little power savings, but restoring to a running system is very quick. This is the default mode if you omit the -m switch.

mem – Suspend to RAM. This offers significant power savings – everything is put into a low-power state, except your RAM. The contents of your memory are preserved.

disk – Suspend to disk. The contents of your memory are written to disk and your computer is powered off. The computer will turn on and its state will be restored when the timer completes.

off – Turn the computer off completely. rtcwake’s man page notes that restoring from “off” isn’t officially supported by the ACPI specification, but this works with many computers anyway.

no – Don’t suspend the computer immediately, just set the wakeup time. For example, you could tell your computer to wake up at 6am. After that, can put it to sleep manually at 11pm or 1am – either way, it will wake up at 6am.

Seconds vs. Specific Time

The -s option takes a number of seconds in the future. For example, -s 60 wakes your computer up in 60 seconds, while -s 3600 wakes your computer up in an hour.

The -t option allows you to wake your computer up at a specific time. This switch wants a number of seconds since the Unix epoch (00:00:00 UTC on January 1, 1970). To easily provide the correct number of seconds, combine the date command with the rtcwake command.

The -l switch tells rtcwake that the hardware clock is set to local time, while the -u switch tells rtcwake that the hardware clock (in your computer’s BIOS) is set to UTC time. Linux distributions often set your hardware clock to UTC time and translate that to your local time.

For example, to have your computer wake up at 6:30am tomorrow but not suspend immediately (assuming your hardware clock is set to local time), run the following command:

sudo rtcwake -m no -l -t $(date +%s -d ‘tomorrow 06:30’)

Help

share|improve this answer
    
A nice rtcwake write-up is at this question. It offers complete solution: askubuntu.com/questions/61708/… –  gare Dec 25 '13 at 14:42
add comment

You can try setting up BIOS for a wake up event, Almost every motherboard have that feature, use your mb manual and figure out it, in some AMI bios, it is called Wake up by RTC alarm, I think that is the easy way to wake up the PC at a specific time

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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