Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm writing a shell script to check the I/O activity of a Linux box and if the server is quiet for a certain long time, the script should let the server go to sleep. But, after some Google searching, I didn't find a answer yet. Is there a shell script command to put a Linux box to sleep?

share|improve this question
    
what shell are you using? Bash? –  Peter Mortensen Jun 21 '10 at 11:14

3 Answers 3

To answer your question simply, echo -n mem > /sys/power/state or apm -z should bring your linux system to sleep, depending on whether it uses ACPI or APM. However not all is necessarily happy, and you might want to take a look at this article about how to restore the video memory and sleep a system properly from a shell script.

share|improve this answer

If your setup supports hibernation you can use the sys interface

echo -n mem >/sys/power/state

to suspend to ram and

echo -n disk >/sys/power/state

to suspend to disk.

Remind that your kernel and hardware have to support it to use it.

share|improve this answer

Using the handy pm-utils package, you can issue commands to suspend and hibernate without echo'ing values to the system. For example:

$ pm-suspend
$ pm-hibernate
share|improve this answer

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.