Say it isn’t so — my Macbook will not sleep! When I abandoned Windows for a Macbook, I hoped I would resolve a problem with not sleeping (entering sleep mode) that I have posted about before — my Windows XP Sleep and Hibernation posts continue to generate thousands of views, but alas, Snow Leopard, OS X doesn’t always sleep, either.
I have done a fair amount of research and think I understand why my macbook will not enter sleep mode, and how the OS X sleep process works. And importantly (and unlike Windows): what you can do to resolve the issue. The short answer is: there’s no built-in way to ensure your Mac goes to sleep automatically, but there’s a great bit of free software you can install, which in my tests works perfectly: PleaseSleep.
PleaseSleep will save me around $25/yr in wasted electricity (assuming I use it six hours a day, and it sleeps 18 hours). It will also prevent some unexpected battery depletion when I travel.
The Staggering Cost in Energy and Dollars of Sleepless Computers
If there are indeed a billion personal computers in the world, and for sake of argument 10% of them are suffering some sort of insomnia, and 10% of them are Macintoshes, that’s 10 million computers trying but failing to go to sleep. Let’s say I am over-estimating by 10 times, we’re talking about 1M computers that are sleepless. If each of them was like mine, needlessly using 20 watts for 18 hours a day, that would be a lot of watts, simply wasted.
Math? 20W * 18 hours/day = 360W/day/computer, * 1,000,000 computers = 360M Watt hours per day, or 360,000 kWh per day. In the US, the average price of a kWh is $0.10 so that’s about $13M/year in wasted electricity. And that’s just from Macs, assuming they’re all the most efficient ones (like mine) that for one reason or other don’t sleep. And for all of us Mac “fanbois” out there, assuming PCs are as bad and as efficient (they are worse, and less efficient), that’s another $117M/year in wasted electricity dollars. Granted, we probably spend that amount in a day fighting some war, but hey, this is about the things we can control.
My Macbook (late 2008, Unibody aluminum, 13″ screen) uses between 14 and 20 watts when the disks and screen are off — it was designed to use very little energy (one reason I bought it: yes, to be good to the planet, but also: the battery lasts longer). Older models, larger models, non-laptop, and more powerful models will use more if they don’t turn off. So, unless you have my computer or later, assume you have a less efficient model — pay the guy who gives away PleaseSleep accordingly.
So, making a lot of assumptions, my rough guess is that $13,000,000 per year is wasted by Macs that don’t sleep as expected.
But, fear not: we can control our computers. It’s easy (at least in this case). Download and install PleaseSleep for free. Then donate your first six months of electrical savings to the guy who wrote it. For most people (having lower electrical rates), that would be about $5 – $10.
I Think Guilt May Work With Apple (Tried With Microsoft: They Said “Upgrade to Vista”)
If Apple wants to call themselves environmentally responsible (and yes, Apple, you do, I know it’s true), they should spent the day or two it would take to build the functionality of PleaseSleep into their operating system. Heck, take a week and go the extra mile. If one nice guy can write a program to do this, surely Apple can do it, as well.
Heck, Apple should just pay the guy that wrote PleaseSleep $13 million dollars and just do the right thing.
Macintosh Insomnia and Related Sleeping Disorders
All recent versions of Mac OS X have an “Energy Saver” option in the Preferences panel. Preferences are set (and on by default) to turn off the hard disks, turn off the monitor, and then really enter “sleep mode”.
There doesn’t seem to be a problem with hard disk sleeping, nor does there seem to be a problem with turning off the monitor, but depending on your model, when it’s using the processor (doing some computing) the computer itself can use a little or a lot. Of course not all Macs fail to sleep properly. (And some won’t wake up, which I might describe as a more serious ailment.)
Why Macs Don’t Sleep
When a Mac (or other computer) is on, it’s doing various tasks : working. When you browse a website it’s working. When you type it’s working. When you download
porn classical music it’s working.
But other things require the computer to do only a little work in the background: checking for new email, staying connected to the network, seeing if anything needs to be backed up, listening to see if anyone has requested a file on your shared drive, displaying accurate time and so on. Mostly, these kinds of tasks are non-critical. And they are especially not important when you are not using the computer. Yet it is frequently these non-critical tasks that prevent your trusty Mac from sleeping.
The decision about when to sleep is made by your Energy Saving preferences. Think of “Energy Saver” as the parents. “Time to go to bed, kids!”
The decision about whether to sleep could be overruled by any running program. The running programs are not just the ones in the dock that have the dot under them — they are also the ones in the menu bar along the top (the clock, battery indicator and so on). But there are more — so-called “daemons” that are waiting for the most mundane things to happen, in the background, invisible for the most part. If you have little kids they are analogous to “running programs”. If you have “tweens” they are like the menu bar programs. If you have teenagers, they are demons. Oh, I mean “they are like daemons”.
Or do I? Mu-ha-haha!
And of course at least a little of the computer has to be waiting for an indication that it should wake up. Sleep isn’t a dirt nap. It shouldn’t be eternal. Usually a keypress or mouse movement will wake up a sleeping Mac.
But any old program (it’s probably those daemons) can decided to ring the alarm. On my computer, I could get it to sleep manually (e.g. clicking the Sleep item from the Apple menu) … but within a few minutes, it would wake up. Programs that decide to wake a computer are one class of energy wasters — sneaky or passive-agressive ones.
In fairness, about the last thing programmers think about is whether their programs should accept requests to sleep. The trick is that some work is required to accept and respond to a request to sleep. And OS X demurs politely to any whose response is anything other than “Go for it, dude!”. Any one such ill-behaved little whippersnapper of a program can keep everything running. I’m a parent: I know what it’s like.
Why Can’t OS X Just Force Sleep?
Well here’s the thing. There are some programs whose execution is critically important. Or at least convenient. And at the very least some things in progress may need to finish.
At least some things that should wake the computer — the power button, a keyboard press, a mouse motion. Yet depending on how your computer is being used, you may want it to wake for other reasons. If you are sharing a folder for others at home, they may want to be able to get at it. If you screen-share with a computer at work, it will need to wake up. If your computer is a web server or database server it may not even want to go to sleep at all. Maybe you want your BitTorrent download to complete before the computer sleeps.
But when a program goes to sleep, it may have to do a few last things before bed. The network connection may need to alert the network, files open may need to be closed and stuff like that. The computer needs to make sure it’s in a consistent state so that when it wakes up, it will know what to do if things are a little different than when it slept. Maybe the network went away. Maybe the other computer sharing files or using your shares went away.
Once things are tidied up, OS X keeps everything in memory and remembers a few details about each of the processes running — a snapshot of the computer’s “state”, at which point it needs to do very little work, and sets the processor to idle state, and saves electricity … a lot. And if I am not mistaken, this state information is written to a compressed file on the disk so that in the case of power failure, the computer can still resume (this is known as hibernation).
How To Determine Which Program Is Preventing Your Mac From Going to Sleep
OS X does a lot better than Windows XP (the last version I used regularly) — it does create a log of such requests to sleep. And Macs tend to have a lot less junk installed on them — a favorite ploy of PC makers to get more money by installing crippled versions of software in hopes you’ll upgrade.
But in the end, OS X merely records the request to sleep, it does not force. You really have to be a geek to identify when a request to sleep was denied and figure out who. “Why it’s simple” (my co-geeks will say) — “just look at kernel.log through the Console!” Simple, for example, last time I moved my mouse when the computer was sleeping, here’s what Console (looking at kernel.log, of course) told me:
Sep 26 17:55:19 macbook kernel: sleep
Sep 26 17:55:19 macbook kernel: Wake reason = EHC2
Sep 26 17:55:19 macbook kernel: System Wake
Sep 26 17:55:19 macbook kernel: Previous Sleep Cause: 5
Sep 26 17:55:19 macbook kernel: USB (EHCI):Port 2 on bus 0x26 has remote wakeup from some device
Sep 26 17:55:19 macbook kernel: en1: 802.11d country code set to 'X0'.
Sep 26 17:55:19 macbook kernel: en1: Supported channels 1 2 3 4 5 6 7 8 9 10 11 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 149 153 157 161 165
Sep 26 17:55:20 macbook kernel: The USB device USB Receiver (Port 2 of Hub at 0x26200000) may have caused a wake by issuing a remote wakeup
So a hint: open Console.app (from Finder in Utilities), find the kernal.log from the list, and search on “wake” or “sleep”. Once you have found something plausible, note the time, and scroll to that time to see everything that’s happening. Of course, perhaps you’re not enlightened when you see crap like the above and say, “Aha, now I know what’s wrong!” You are like the other 98.9% of humanity, and perhaps the other 99.998% of people who bought Macs because they would never have to deal with such things, fear not.
For the rest of us (an elite bunch of nerds, I like to think), at least it’s possible. Why then we can write up useful blog posts that people will find and click on. But I think that’s really not the Mac/Apple way. I really think there should be a better part of OS X to do more than silently and obtusely record these events in some godforsaken log.
Indeed PleaseSleep has a nice little log of its own. And that helped me identify one problem preventing my computer from sleeping: one of my keys, or the touchpad was saying it was pressed … or something; enough to make Mac stay awake.
Links And Resources To Sleep Issues
- Apple’s Explanation of How Sleep Works
- Apple’s Explanation of Why Sleep Can Fail
- About 50 Suggestions, None of Which Worked for Me, But Might for You
- Implications that Upgrading to Snow Leopard Cause Sleep Issues, which I did, but none of the diagnostics suggested I had any issues
- More Stuff from Apple About Why Sleep May Not Work, None of Which Applied to Me, But Might for You