What is preventing my MacBook from sleeping?
I have a MacBook Air and I have noticed that even though I have configured it to put itself into sleep mode after being inactive for 5 minutes it sometimes stays awake.
I've usually got a bunch of programs open (Tweetie, iTunes, Safari, iChat etc) but it there some way I can find out which program/process that is preventing the MacBook from sleeping? (Yes, I know that I could probably reboot the MacBook and try one program at a time but that is pretty tedious)
Try this. It might work for you.
Go to Utilities in the Applications folder and open the "Terminal" app.
Type
pmset -g
and hit EnterIf "sleep" has 0 next to it and the words "imposed by" or "prevented by ; The number next to the imposed by is the process ID causing the problem. Copy that number.
Type
ps -e | grep <process ID here>
and hit Enter. This will list all running processes that have that ID (will also include thegrep
process)
In my case it was process id 19 which turned out in this instance to be a print server process. I went to "Print & Scan" in System Preferences and reset deleting all installed printers from there. . . Problem solved. I added the one printer that I needed and sleep still works. I don't yet understand quite how printing can get this way with the sleep mode.
"Inactive" is hard to determine from looking at your system. You should use a process monitor, like "top" or "Activity Monitor" and see what is going on. You can quit apps to isolate the problem.
For browsers, flash or other plugins are often the cause. Your average web page is much more CPU intensive than it was a couple years ago. Also, background downloads probably also keep it from sleeping.
Try to use the command:
pmset -g
It will sometimes display the processes preventing your mac from sleeping.
Source: http://www.macobserver.com/tmo/article/osx_lion_pmset_shows_app_imposed_sleep/