|
|
#1 |
|
Prospect
Join Date: Feb 2002
Location: Albuquerque, NM
Posts: 2
|
The sleep on OS X really has me baffled. My wife is trying to finish her dissertation in biology, and she's been running genetic analysis software for a while now. When she got fed up with OS 9 crashing, I suggested she use OS X. These analyses can run for days on an 800 MHz G4, so they're moderately big.
After we started running the analysis program, we discovered that it was grinding to a halt when the Mac went to sleep. I have never used a Unix machine that slept, so this was somewhat new to me. One option, of course, is to not allow the machine to go to sleep using the Energy Saver prefence window. This seems inefficient we'll undoubtedly forget to put it to sleep. The ideal solution would be to have a check built in for whether the machine is actually running. Before OS X goes to sleep, it could check to see if the processor is being utilized more than, say, 50% and stay awake if it was. Does anyone have any suggestions on how to approach this problem? I'm not even sure where to begin in modifying the sleep mode. On a similar note, does anyone have any practical experience with the options under the Energy Saver panel? There's an option to wake when the modem "detects an incoming call" and something about waking for administration over the network? Will either of those allow me to wake my Mac remotely using SSH? Also, why are these Energy Saver options available on my machine at work (733 G4) and not on the one at home (223 G3) both running 10.1? I'd appreciate any suggestions, Tracy |
|
|
|
|
|
#2 |
|
Triple-A Player
Join Date: Jan 2002
Location: Toronto, Canada
Posts: 185
|
Check for load
The following script will put the computer to sleep if the CPU load has been less than 0.8 (i.e. pretty busy) for the last fifteen minutes (uptime gives you the load for last 1, 5 and 15 minutes ). You can change that to anything between 0 and 1.
Code:
set theLoad to do shell script "uptime | awk '{ print $12 }'"
if (theLoad as number < 0.8) then
tell application "Finder"
sleep
end tell
end if
0 * * * * "open busy" to run it every hour. The script works, I just tested it. The cron job could probably be tweaked a bit. Get Cronnix on http://www.versiontracker.com for that. For the wake on Rings, it works: if your modem is connected and the computer is sleeping, you can wake it up. For Admin Network access, I am not sure exactly what they consider "Admin Access". Ping definitely is not and I believe I tried SSH from work once and it did not work. Last edited by Novajo; 02-12-2002 at 10:44 AM. |
|
|
|
|
|
#3 |
|
Prospect
Join Date: Feb 2002
Location: Philadelphia, PA
Posts: 3
|
Strangely, this script works when I run it from the command line, but doesn't when I get cron to run it. I've added a log to check that cron is indeed running the script & that uptime is below 0.8. Both these things are happening. It seems that the tell statement is just not having the desired effect. Any ideas?
|
|
|
|
|
|
#4 | |||||||||||||||||||
|
Prospect
Join Date: Jan 2002
Posts: 11
|
Re: Check for load
Uhm, so, does your computer wake up once an hour and then go back to sleep? My cron entries wake my mac up (I _really_ wish they didn't) Thanks |
|||||||||||||||||||
|
|
|
|
|
#5 | |||||||||||||||||||
|
Prospect
Join Date: Feb 2002
Location: Philadelphia, PA
Posts: 3
|
no... that's the thing... the script runs, gets (sometimes) <0.8 for the load, but doesn't go to sleep. If I run the same script from terminal.app it works fine. There's clearly some permission problem somewhere.
That's odd that cron entries are waking your mac up. I had the impression that one of the possible drawbacks of cron is that it doesn't execute while system is sleeping. --mk
|
|||||||||||||||||||
|
|
|
|
|
#6 |
|
Triple-A Player
Join Date: Jan 2002
Location: Toronto, Canada
Posts: 185
|
Got it
The cron job executes, but the following error is obtained:
zsh: command not found: open sleep (it gets mailed to you if you have sendmail configured properly. I check with "mail" in the terminal). That said, the proper entry in cron should be: 0 * * * * /usr/bin/open /path/to/busy use the full path to "busy" (and open) with no quotes. Also, you could probably use something like: 30 3 * * * /usr/bin/open /path/to/busy to actually run it right after the daily, weekly cron jobs (which I believe are running at 3:15). I just tested it and it works well. regarding other comments though: 1) It does require that the finder be running. If you are logged out, the "Tell Finder" command will probably fail (or will the finder start up??) 2) The cron job does not wake up the computer. The system is not running, the processor is not even running. Therefore cron jobs do not execute. Last edited by Novajo; 02-12-2002 at 10:46 PM. |
|
|
|
|
|
#7 | |||||||||||||||||||
|
Prospect
Join Date: Jan 2002
Posts: 11
|
Re: Got it
My cron jobs wake my Mac from sleep, and prevent it from sleeping when they are running. That is what occurs, I really wish it didn't. Are you saying that you know that cron jobs are not supposed to wake a sleeping computer, or that they do not wake yours? Thanks |
|||||||||||||||||||
|
|
|
|
|
#8 |
|
Triple-A Player
Join Date: Jan 2002
Location: Toronto, Canada
Posts: 185
|
What is the cron job you are referring to? Give the full crontab line.
When my computer goes to sleep at night (manually), it does not wake up at 3AM for the daily cron job. How about yours ? |
|
|
|
|
|
#9 | |||||||||||||||||||
|
Prospect
Join Date: Jan 2002
Posts: 11
|
Here is my 3AM Daily: sh /etc/daily 2>&1 | tee /var/log/daily.out | mail -s "`hostname` daily output" root It DOES wake my Mac up at 3AM. So... my Mac g4/466 10.1.2 setup is screwy? Thanks |
|||||||||||||||||||
|
|
|
|
|
#10 |
|
Prospect
Join Date: Feb 2002
Location: Albuquerque, NM
Posts: 2
|
The hourly cron job is a start, but it doesn't have all the functionality of the Energy Saver Panel. For example, if I'm sitting here reading posts on this site and not doing much but occasionally opening windows and scrolling, the hourly cron will cause the computer to go to sleep. So the test needs a Boolean AND on CPU load and, say, mouse movement? How can we access that information?
The "wake on ring" is only for the internal modem not the ethernet, right? I haven't seen a case where the "wake for network administrative access actually wakes the computer. Has anyone? Tracy |
|
|
|
|
|
#11 |
|
Triple-A Player
Join Date: Jan 2002
Location: Toronto, Canada
Posts: 185
|
Wake on rings is for modem. I have not seen the "Wake on Network Admin access" option work. As I said, I don't know what Admin access is in terms of TCP/IP connections.
For the mouse movement, I suggest to monitor the screensaver since it does monitor mouse movement and all. If the screensaver is ON, then it's highly likely that you are not using your computer, and then if the CPU usage is low, then nothing is happening and you should put the computer to sleep. Of course, that forces you to take a screensaver module and activate it. Also, you will want to pick one module that does not use CPU time too much 1) to make sure the load remains low and 2) to leave your CPU cycles to your calculations anyway. I guess you could add something like this to the AppleScript: set theScreensaverIsOff to ((do shell script "ps -axl | grep 'ScreenSaver' ") is equal to "") and then if load < 0.8 and theScreenSaverIsOff , etc... It's quick and dirty, but would do the job. (I don't have access to my OS X machine right now and can't test it). |
|
|
|
|
|
#12 | |||||||||||||||||||
|
Triple-A Player
Join Date: Feb 2002
Posts: 51
|
Re: Re: Got it
I think you are mistaking disk activity for waking up. Cron jobs don't wake the processor if it is truly asleep, but they will cause the disk to spin up if it has been stopped. If the processor is fully asleep though cron does not wake it, at least that's how my cube and ibook behave. I would like the processor to wake for cron, or at least have a scheduled way to wake it. |
|||||||||||||||||||
|
|
|
![]() |
|
|