Why won't my mac sleep?

Recently I was asked if there was a way you can find out what is preventing a mac from sleeping, my friends MacBook had stopped going to sleep. I told him to use the pmset command.  Pmset is a way you can read and change many of your power management settings for your device.

On this occasion if you use the -g flag it shows you the current settings, this is from my machine below.

Last login: Mon Nov 7 20:02:37 on console

Macintosh-4:~ craigrichards$ pmset -g

Active Profiles:

Battery Power -1

AC Power -1*

Currently in use:

womp 0

autorestart 0

halfdim 1

sms 1

panicrestart 157680000

hibernatefile /var/vm/sleepimage

networkoversleep 0

disksleep 0

sleep 60

hibernatemode 3

ttyskeepawake 1

displaysleep 10

acwake 0

lidwake 1

Macintosh-4:~ craigrichards$;

If your Mac had failed to sleep the line that says sleep 60 would say

sleep 0 (imposed by ####) The hashes would be replace with some numbers.

Those numbers are the Process ID of whatever is stopping your machine from sleeping.  Once you have the process id, you can track down the application.  While you are still in the terminal you can type

ps -ef | grep #### (replace the # with your process id) then press return.  

It will then display the application that was preventing sleep.  If you are not happy with staying in the terminal then you can use Activity Monitor.

Below is a screenshot of Activity Monitor, if you click on the PID column as shown in the arrow it will place them in order so you can find the troublesome process quicker.

I am waiting to hear back from him to find out if this resolved his issue, in the meantime if you have any additional tips on how to resolve these issues then please comment below.

I am always interested in feedback so please feel free to add any comments, or you can mail me  here.  If you would like to submit a quick tip  with full credit and links back to your site then also feel free to contact me.  

Evernote - Find notes without tags

Turn long commands into a script