Mac does not sleep automatically in Lion!

Solution 1:

Another safe boot revealed that the auto sleep mode actually is working. I believe that it would probably have worked the last time I've tried it as well - but, since the sleep occurs several minutes later than the time defined in the Energy Saver settings, I did not notice this.

What about the 'normal' boot?

I've basically tested the auto sleep with all my menu extras enabled one by one, because the iotop command mentioned by @StuWilson didn't show anything helpful to me. As it turns out the menu extra Stack Exchange Notifier caused insomnia.

Solution 2:

The biggest cause of macs not entering idle state is usually disk activity.

I'd suggest that you boot into Safe Boot mode then use Activity Monitor to see if any processes are causing IO operations.

If you do see activity then try using iotop in terminal, it will give you a breakdown of Process ID (PID) and the app or process name doing the IO operations.

sudo iotop -C 5 10

Solution 3:

This might not be your problem, but I've had the same issue for a long time and couldn't find an answer for me, so I'll post what worked for me in case someone comes along later.

My MacBook Pro (and later, my iMac, since I used Migration Assistant) would not sleep when left idle for anything. It would sleep with the lid closed, or if I explicitly told it to, but would not sleep when left alone, as it should have per my preferences in Energy Saver.

I had already checked pmset -g assertions and turned off sharing and other wake-on-LAN settings, and nothing seemed to work. Monitoring pmset -g pslog, I found that the computer would go to sleep at the scheduled time, and wake back up a few seconds later, reporting as wake reason only whatever had been called last—even if it was the power button (that is, it said I had pressed the power button when I had not. That scared me). I had read this and a dozen other answers and forums and couldn't get anywhere.

I found a hint by checking pmset -g log which was a little more detailed than pslog. It turned out that every time the computer went to sleep, a process "cancelled" like so:

3/13/13 12:00:12 AM CDT  Sleep                  Software Sleep Sleep: Using AC                                              6492 secs 
3/13/13 12:00:12 AM CDT  Cancelled              Kernel: Response from WDDMService is to cancel state change                 

Looking up WDDMService in Activity monitor, it turned out to be a background daemon that was installed by the notorious "SmartWare" that came on a Western Digital External drive. So I killed the process, and the computer went to sleep as it should! Since I don't use the software, I removed it from launchd (which I think it called the .plist? I didn't really know what I was doing there) so it wouldn't appear again. Everything works fine now!