Auto sleep based on CPU usage

Feb 12, '02 01:44:37PM

Contributed by: robg

In this Intelligent sleep/energy saver? thread on the forum site, Novajo offers up a script that can be used to put your Mac to sleep based on CPU load. The script is quite short:

set theLoad to do shell script "uptime | sed 's/.* //g'"

if (theLoad as number < 0.8)
tell application "Finder"
sleep
end tell
end if
Save the script, make it executable, and then use 'cron' to schedule it to run at regular intervals, and your Mac will put itself to sleep when the CPU load has been below your threshhold.

The forum thread has more info on the cron task if you'd like to see how that step is done...

[Editor's note: Script changed to reflect comments posted below - thanks all!]

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020212134437163