Have you ever been annoyed to find that your Mac won't got to sleep when you tell it to? It turns out that in Mac OS X 10.6 and later, there's a simple way of finding out what's keeping your Mac awake.

Run the following command in your Terminal:

pmset -g assertions

In the first section of output, you'll see the status of two kernel assertions named PreventSystemSleep and PreventUserIdleSystemSleep. An accompanying status of 1 for either of these means that it is currently triggered.

The second section of the output lists the processes which owns any enabled assertions, both by process id (pid) and bundle id. If the verbose bundle id doesn't ring a bell, you can always use ps up <pid>, or look in Activity Monitor, to find the name of the exact command associated with this process.

Very interesting — It's an entirely different list of assertions compared to the one I get!

So it appears that the available assertions may depend on the model of Mac you have…? The only two Macs I have access to right at this moment are a MacBookPro4,1 and a MacBookPro6,2… and they both give me identical lists of assertions, including the two I mention in the hint above.

In short, I have no clue. But it would be interesting to investigate this further.

I'm damned near convinced I submitted it under 10.6. At the very least I certainly intended to, because (as I stated in the text) it does appear to work in 10.6+. The text of my submission was altered somewhat, so it might be that the site admins changed the category as well.

I put it under 10.7 because it works in Lion, and because most users who read the site run Lion. I was afraid that if I put 10.6, people wouldn't think it works in. But the text of the hint does say 10.6 and later.

Yet another reason to look further into a tagging system for the hints so that you can further qualify it. BTW: if it says 10.6 even though I run 10.7 or later I typically look at it to see if it is something that might apply to later versions also. I do not assume however that if it says 10.7 that it will work in earlier because to me the specific later version typically implies that the later version is what is required.

If your Mac is simply delaying before sleep, you're ok. The computer is probably doing some clean up or set up prior to sleeping.

On the other hand, if your Mac is not sleeping at all after you either tell it to sleep or have it set in the Energy Saver System Preferences, this hint is for you.

For example, last week my Mac started to not sleep anymore. I came across this hint and it showed me out to figure out that it was because I turned on Internet Sharing (from the Sharing System Preferences) and that prevented system sleep.

Thanks for this helpful hint. I was hoping it would get me to the bottom of what's been consistently happening with my MacBook Pro - even two calls to Apple Tech has not solved it. Simply put, my MacBook (running Lion 10.7.4) will not go to sleep by itself, no matter what we've tried. It will go to sleep when you tell it to go to sleep, but no matter what the Energy Savings setting are set to, it will never goes to sleep on it's own.

Running the script you suggested returned the following, so I'm not sure this script helps my issue.