For some reason I've always had trouble getting my 27" iMac to sleep when it was supposed to. I spent a lot of time searching forums and trying a dozen or so different things offered up by users and Apple alike. A few times I found something that seemed to work, only to find my Mac awake again in the middle of the night. It turns out there are literally hundreds of things capable of rendering your Mac a total insomniac. Everything from Bluetooth connections to wonky external hard drives can be the culprit. The process of elimination can take forever. How do you shorten the list without trying everything one at a time? Well, thanks to a post at
Macworld, I learned once again that the command line would come to my rescue. This simple command:
pmset -g assertions
will result in a list of processes "asserting" themselves on OS X. Something like this...

...showing the number of processes doing things to your system. The two concerning system sleep prevention are PreventSystemSleep and PreventUserIdleSystemSleep. If either of these have a process count greater than zero then you need to look further to find out what they are. The command results go on to list (in order) specific processes assocoated with non-zero values in the above list...

As you can see, the AppleFileServer process was the culprit in my case. Obviously, some other machine on my network was connected to a share on my iMac, preventing it from snoozing. If your case is not so obvious, you can lookup the pid (process identification) in Activity Monitor (in this example, pid 666) to see if you can glean more information. Activity Monitor lets you sort active processes by pid, making things easy to find and even easier to quit.
Article originally appeared on Fighting the Left. TEXAS STYLE! (http://mactexan.com/).
See website for complete article licensing information.