Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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

share|improve this answer
Nice answer. It really is more fruitful to also make this a small lesson in the unix philosophy. +1 – Steven D Sep 7 '10 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.

share|improve this answer

Your Answer


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.