You can use the following commands under Linux to suspend or Hibernate Linux system:
- pm-suspend Command - During suspend most devices are shutdown, and system state is saved in RAM. The system still requires power in this state. Most modern systems require 3 to 5 seconds to enter and leave suspend, and most laptops can stay in suspend mode for 1 to 3 days before exhausting their battery.
- pm-hibernate Command - During hibernate the system is fully powered off, and system state is saved to disk. The system does not require power, and can stay in hibernate mode indefinitely. Most modern systems require 15 to 45 seconds to enter and leave hibernate, and entering and leaving hibernate takes longer when you have more memory.
- pm-suspend-hybrid Command - Hybrid-suspend is the process where the system does everything it needs to hibernate, but suspends instead of shutting down. This means that your computer can wake up quicker than for normal hibernation if you do not run out of power, and you can resume even if you run out of power.
Linux Command To Suspend System
To suspend system, enter:# pm-suspend
OR
$ sudo pm-suspend
Linux Command To Hibernate System
To hibernate system, enter:# pm-hibernate
OR
$ sudo pm-hibernate
How Do I Put My Computer To Sleep After a Certain Amount Of Time?
You can use the at command as follows to put laptop to sleep after 30 minutes of time:
echo 'pm-suspend' | at now + 30 minutes
How Do I Add Hooks (or so called scripts) When My System Is Suspended?
You can place your scripts in following directory. They are executed at suspend and resume:- /etc/pm/sleep.d - Almost all distro including Debian looks here first to run script.
- /usr/lib/pm-utils/sleep.d - Default Debian location.
Sample Shell Script
#!/bin/sh
# If we are running NetworkManager, tell it we are going to sleep.
# TODO: Make NetworkManager smarter about how to handle sleep/resume
# If we are asleep for less time than it takes for TCP to reset a
# connection, and we are assigned the same IP on resume, we should
# not break established connections. Apple can do this, and it is
# rather nifty.
. "${PM_FUNCTIONS}"
suspend_nm()
{
# Tell NetworkManager to shut down networking
dbus_send --print-reply --system \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \
org.freedesktop.NetworkManager.sleep 2>&1 > /dev/null
}
resume_nm()
{
# Wake up NetworkManager and make it do a new connection
dbus_send --print-reply --system \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \
org.freedesktop.NetworkManager.wake 2>&1 > /dev/null
}
case "$1" in
hibernate|suspend)
suspend_nm
;;
thaw|resume)
resume_nm
;;
*) exit $NA
;;
esac
No comments:
Post a Comment