PDA

View Full Version : how to sleep/suspend on desktop?



dedded
30th September 2005, 12:58 AM
I've searched through these forums, and on Google, for instructions on how to suspend my system, which is a desktop and not a laptop.

The only instructions I've found have been for laptops, and I haven't been able to get them to work on my system at all.

I'd like to be able to suspend to RAM (and/or disk, but RAM especially) with FC4 on my desktop. I don't want to have to boot my system each night, and I don't like the idea of burning all that electricity through the workday and the night (and most of most evenings) when I'm not using the machine.

So,
- Is suspend possible with FC4 on a desktop?
- Do I need something not available through core or extras?
- How do I do it?

Any help greatly appreciated.

/Dan

kenm_uk
4th October 2005, 11:02 AM
Dan,
Did you see the following post? I found it useful...
http://fedoraforum.org/forum/showthread.php?t=74326&highlight=suspend

But now I am trying to figure out how to have the machine automatically wake up at a certain time...if you find anything please post it.

Ken

scoon
4th October 2005, 01:45 PM
Hey there,

Good luck on your search. The reason that you are finding more info on lappys is that they do not have unlimited power like a desktop does. There is usually no reason to sleep a desktop. Which leads into my next question: Why do you need to do this ?

regards,

scoon

kenm_uk
4th October 2005, 02:29 PM
Scoon,

Thanks for your reply. The reason I want to sleep my server is that I do not want to run it 24/7 because it would be a waste of power and wear on the machine. I use it to host a multiplayer game which I want to play only in the evenings from a remote location. So I am trying to figure out how to get the box to sleep until 7pm and then start up to serve the multiplayer game.

Anyway, I think I have found the solution:
echo YYYY-MM-DD HH:MM:SS > /proc/acpi/alarm
and then sleep the machine with
echo "mem" > /sys/power/state

I tried it once and it put my server to sleep and woke it up on time. What would be a bit more ideal is if I could somehow wake it remotely on demand. Like Wake-on-LAN. but I don't think I can do this through a DSL-604+ router over the internet.

If you have any thoughts or recommendations please share.

Cheers,
Ken

brandor
4th October 2005, 03:02 PM
Have you thought about setting up a cron job? Maybe have it run the commands you listed above at 3 in the morning or something? That way it wouldn't be running all day and would give you plenty of time to play your game.

kenm_uk
4th October 2005, 07:57 PM
brandor,

Thanks for your reply. A cron job would do the trick for adding the next alarm time to the alarm folder and then running the suspend command. I am just a bit too new to Linux to have worked out how to write my own scripts. Any thoughts on where I could find such a script? Basically all I need it to do is to put in today's date with the time 19:00 in the alarm file and then run the echo "mem > /sys/power/state command to be run by cron at 3am. BUT...if I happen to be using my server at 3am (either locally or remotely) it would be nice to see a warning which would allow me to abort the shutdown.

Anyway that is TOO MUCH for me to do now. But if you could recommend a good book or site on how to write a script that would be much appreciated.

Cheers,
Ken

dedded
5th October 2005, 03:28 AM
This command does absolutely nothing on my machine:
echo "mem" > /sys/power/state

At least nothing that I can observe. It certainly doesn't put it to sleep. I assume this is all system-dependent. I'm on a Dell 4600 (ICH5-based) running FC4.

To answer another's post, I want to suspend my desktop to save power. Shutting down and later rebooting would also save power, but it's very inconvenient. Of course it's a bigger issue on a laptop, but it's still relevant for desktops.

/Dan

kenm_uk
5th October 2005, 09:10 AM
Dan,

I am just a newbie so not sure if I'll be of much help. I'll tell you what I have read and maybe oters will comment.

First, I think your motherboard must be acpi compatible (which I believe yours is). Second, it may need to be enabled in the BIOS settings. Third, you may need to be running the acpid deamon (not sure).

I found the following site of use:
http://acpi.sourceforge.net/

Ken

dedded
5th October 2005, 12:56 PM
> First, I think your motherboard must be acpi compatible (which I believe yours is).

I believe so, too. Both suspend to RAM and suspend to disk work on Windows XP.

> Second, it may need to be enabled in the BIOS settings.

Well, works in Windows. Same BIOS.

> Third, you may need to be running the acpid deamon (not sure).

That's definitely running.

Thanks for the site, I'll check it out.

/Dan

GrayFox
6th October 2005, 04:15 AM
Here is some code that works on my HP DV4000.
I was having problems with the screen not "waking up" after
a suspension, but I found (quite by accident) that changing
the console to a straight text console and then back to the
X console that the video would come back on...

Jerry

[jerry@localhost ~]$ more standby.c
// standby.c

// Author: Jerry LeVan
// Date: Sept 9,2005
// Build: make standby
// Env: HP DV4000, Fedora Core 4, a reasonable version of acpi
// Build: make standby
// sudo chown root standby
// sudo chmod u+s standby

// A short program to put the laptop
// to sleep. Toggling the door switch
// or hitting a key will awake the computer.

#include <unistd.h>
#include <stdlib.h>

int main (int argc , char** argv)
{
char * cmd = "/bin/sh" ;
char * theOpt = "-c";
char * theArg =
"sync;sync; /sbin/modprobe -r uhci_hcd ehci_hcd ; \
echo mem > /sys/power/state ; \
/sbin/modprobe uhci_hcd ; /sbin/modprobe ehci_hcd ; \
chvt 1 ; chvt 7 ; /sbin/ifup eth1 ; /usr/sbin/anacron -s ";


// the setuid will ensure that the exec'ed shell will run as root
setuid(0);

// Get the ball rollin...
int status=execl(cmd,cmd,theOpt,theArg,NULL);

(void)exit(0);

}

kenm_uk
7th October 2005, 02:16 AM
I am trying to get my machine to wake at a particular hour (say 8pm). I used:
echo 2005-10-(*DATE*) 20:00:00 > /etc/acpi/alarm
which seemed to work once or twice a few days ago but is no longer waking my server at the designated time.
Does anyone know what the problem might be?

Cheers,
Ken

P.S. I read something about how rebooting the machine affects the RTC which causes the alarm not to wake the system. But I did not quite understand what they meant or if that is affecting me.

GrayFox
7th October 2005, 06:19 PM
I am trying to get my machine to wake at a particular hour (say 8pm). I used:
echo 2005-10-(*DATE*) 20:00:00 > /etc/acpi/alarm
which seemed to work once or twice a few days ago but is no longer waking my server at the designated time.
Does anyone know what the problem might be?

Cheers,
Ken


Hi Ken,

Where did you find the doc that echoing the date/time to /etc/acpi/alarm would
awake the machine?

I can do this on my MacOS X machine ( using the power manager) but have not
been able to figure out how to set a wakeup call in FC4.

Thanks,

Jerry

kenm_uk
8th October 2005, 02:33 AM
GrayFox,
I think that "/etc/acpi/alarm" may have been a typo. My previous post read "/proc/acpi/alarm". I will try that and see if my machine wakes on time. Will let you know.

Ken

Firewing1
8th October 2005, 05:30 AM
Hey,
I have the same problem as in the old post. echo "mem" just sounds like it shuts down the harddrives. Nothing happens. Right away, screen goes blank, and HD's shut off. Not much time to save everything to memory... Anyway, when I hit the power button again, my CRT monitor won't come back on even though the computer will. I use a Dell and i can standby in XP so i know it works...
Firewing1

kenm_uk
8th October 2005, 12:22 PM
Firewing1,
By "mem" I think that the machine goes to sleep and stores everything in the RAM. Since everything already is in the RAM there is not much for it to do. My machine shuts off the fans, hard drives, and the only sign that it is still somewhat on is that the power light blinks (indicating it is asleep).

When I wake the machine, I am also having difficulty getting it to restart my USB mouse/keyboard and to start up my monitor (on a Nvidia card). I may have found a solution to the USB problem, but am still having problems with the video issue.

But I am just a newbie trying to figure this out as I go along. Let me know what/if you find.

Ken

Firewing1
8th October 2005, 04:07 PM
Same here! I'm also using an Nvidia... maybe it's a bug
@GrayFox, the echo command would only make it happen once, I think. EG: When you echo "mem" to /sys/power/state, it will erase itself when you come back. Otherwise, as soon as your system would start, it would enter "mem" sleep! You would never ba able to use it again. So, if I'm correct, you'll have to make a cron job to echo time to the alarm every day. Remember, cron wont run in sleep! So the cron will have to echo it while it's powered on (eg the night before) and then it will sleep, and wake when nescissary.
Firewing1

kenm_uk
8th October 2005, 04:44 PM
GrayFox

I just wrote my first script today. It allows you to input when you want your machine to wake (i.e. number of seconds, minutes, or hours from now), saves it to the alarm file, then sleeps the computer. It is pretty basic (took me a while because it was my first script, but you could probably write something similarly quickly...but I'll post the code here when I get home).

Anyway, the sleep and wake works fine but I just need to figure out how to get my monitor to come back on. In the meantime I have been SSHing into the box from a second machine.
Any help would be greatly appreciated.

-Ken

P.S. Which kernels are you all using? From what I read the acpi files vary between kernel releases.

jsimmonds
8th October 2005, 05:11 PM
Running a desktop all night does not waste that much power, mine runs 24/7 so I don't damage the HDD and so everything runs more effectivly

kenm_uk
8th October 2005, 05:14 PM
jsimmonds,
I am not so sure about the power issue. My linux box runs a 2.5GHz processor with 4 hard drives and two powerful case fans. How many watts would you say the machine uses on idle?

GrayFox
8th October 2005, 05:51 PM
Ken,

Did you look at the program/script I posted earlier in this thread? I was having a problem
with the video not coming back on after a "sleep" but I found that changing to a text (virtual)terminal
and back to the x window (virtual) terminal [chvt 1 ; chvt 7 ] seems to wake up the
video again.

Jerry