In windows there is a tool you can use to find out what is preventing sleep.
How can you do a similar task on mac os lion?
To find out why your system won't sleep, type:
pmset -g assertions
In my case, I saw:
Listed by owning process:
pid 63: [0x0000012c0000003f] PreventSystemSleep named: "org.cups.cupsd"
cups is the printing system, so I went into the system prefs and deleted my printer drivers. The system then slept.
pid 117: [0x0000012c00000075] PreventUserIdleSystemSleep named: "com.apple.audio.'AppleHDAEngineOutput:8,0,1,1:0'.noidlesleep"
Thanks for your help Talmy.
But I've even tried closing all apps and it still seems to be sporadic. Sometimes it'll sleep, others not. And afaik I'm not doing or running anything different.
Some apps have background processes you don't see in the Dock. You may need to use Activity Monitor and look for those apps and kill the processes.
To find out why your system won't sleep, type:
pmset -g assertions
In my case, I saw:
Listed by owning process:
pid 63: [0x0000012c0000003f] PreventSystemSleep named: "org.cups.cupsd"
cups is the printing system, so I went into the system prefs and deleted my printer drivers. The system then slept.