I am using Fedora 13 and for shutting down and rebooting automatically, we have the following commands:

# shutdown -h/-r now 

Similarly, if I want to make my system go into suspend mode after sometime, what command should I use?

3 Answers 3


The unix philosophy is to have tools that perform one job, plus the shell to combine them. So we'll combine a suspend command with a do-something-later command. I don't know what the standard command for suspending is on Fedora (there are several floating around); I'll use pm-suspend which is the usual command on Ubuntu.

To suspend after X seconds: sleep X && pm-suspend

To suspend at a given time: echo pm-suspend | at HH:MM

  • 1
    Nice answer. It really is more fruitful to also make this a small lesson in the unix philosophy. +1
    – Steven D
    Commented Sep 7, 2010 at 21:52

The pm-suspend utility (which is contained in the pm-utils package and likely already installed on your machine) is what is used to send your computer into suspend mode. Thus to suspend "right now," you can run (as root or using sudo):

# pm-suspend

Unfortunately, pm-suspend does not take a time parameter as far as I know. However, you could write a wrapper script that took a time parameter. Save the script somewhere in your $PATH and chmod +x it. Do not call it "suspend". A simple one may look like this:

#change this following line to wherever pm-suspend lives

#make sure we are root
if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1

if [ -z "$1" ]; then
    echo "mysuspend: time in seconds expected"
    exit 1;
elif [ "$1" = "now" ]; then
    echo "Suspending now!"
    #make sure we get a number.
    echo "$1" | grep [a-zA-Z] > /dev/null
    if [ $? -ne 0 ]; then
        echo "Suspending in $1 seconds"
        echo "mysuspend: time in seconds expected"
        exit 1

sleep "$wait"

Warning: I have not tested this beyond "works for me".

You may consider changing the suspend command to pm-suspend-hybrid which will also save a hibernation file in case you run out of power while suspended.

Other utilities that you may be interested in or that could make your script more robust are pm-hibernate, pm-is-supported.


If you don't have the pm-suspend command handy, and taking 20:30 as example: (Replace it with when you want to suspend (or wake up) eg. tomorrow 1:00 will also work)

sleep  $(($(date --date "20:30" +%s) - $(date +%s)))

&& echo mem > /sys/power/state

Related, you can also tell the machine when to wake up:

rtcwake -m mem -s $(($(date --date "20:30" +%s) - $(date +%s)))

Sometimes it will fail, so this works better:

while sleep 1; do rtcwake -m mem -s $(($(date --date "20:30" +%s) - $(date +%s))) && break; done 

To hibernate instead, just use disk instead of mem on either of these commands. These commands will work on bash. On a more primitive shell, just use `` (backticks) instead of $( ) and drop the $ in front of the $(( )).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .