Ora8 implements timed sleep to memory-suspendtoram

Source: Internet
Author: User
In Windows, there is a software called eyeauard-eye guard, which can set to automatically lock your notebook every time and force you to rest. It is really a necessary tool for people working at the desk all day. After switching to the Fedora platform, I have always hoped to find such a tool. Now it seems that I have not, and occasionally think that I can use sleep in Power Management to work with scheduled tasks to make my notebook sleep regularly, in many cases, you may forget the time when you work. My OS: Fedora8 install gnome-power-

In Windows, there is a software called eyeauard-eye guard, which can set to automatically lock your notebook every time and force you to rest. It is really a necessary tool for people working at the desk all day.

After switching to the Fedora platform, I have always hoped to find such a tool. Now it seems that I have not, and occasionally think that I can use sleep in Power Management to work with scheduled tasks to make my notebook sleep regularly, in many cases, you may forget the time when you work.

My OS: Fedora8

Install gnome-power-manager.

Vim/etc/crontab

Add as follows:

0 8-18 *** root/usr/bin/gnome-power-cmd.sh suspend

NOTE: The above is sleep to the memory, that is, a lot of things are stored in the memory, so that the startup is fast. Because it is stored in the memory, there must be a power supply. The laptop has a battery.

At the beginning, I didn't know that command could be used to sleep, because it was just a mouse click. Later, I found the above. sh file and checked the content. It was a relatively simple script, namely, writing a function, and executing different sleep methods or reboot upon receiving different variables.

The script content is as follows:

CODE: #$1 = method name
Execute_dbus_method ()
{
Sending-send -- session -- dest = org. freedesktop. PowerManagement \
-- Type = method_call -- print-reply -- reply-timeout = 2000 \
/Org/freedesktop/PowerManagement \
Org. freedesktop. PowerManagement. $1
If [$? -Eq 0]; then
Echo "Failed"
Fi
}

If ["$1" = "suspend"]; then
Echo "Suspending"
Execute_dbus_method "Suspend"
Elif ["$1" = "hibernate"]; then
Echo "Hibernating"
Execute_dbus_method "Hibernate"
Elif ["$1" = "reboot"]; then
Echo "Rebooting"
Execute_dbus_method "Reboot"
Elif ["$1" = "shutdown"]; then
Echo "Shutting down"
Execute_dbus_method "Shutdown"
Elif ["$1" = ""]; then
Echo "command required: suspend, shutdown, hibernate or reboot"
Else
Echo "command '$ 1' not recognized, only suspend, shutdown, hibernate or reboot are valid"
Exit 1
Fi


From: Vincent in the rain

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.