Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a MacBook Pro running Lion. Usually, I need to run tasks that takes hours... so I just leave the laptop working before going to bed.

When I wake up, I notice that it tried to shutdown the system. How do I notice this? Well... all apps are closed except for iTerm (which always stops shutdown process when there is more than one tab open).

I tried to search the energy saving settings but there is nothing related to this... I would like to see how to prevent this behavior.

share|improve this question
  1. Make sure your power adapter is connected to the Mac while you are sleeping.

  2. In the Power Adapter section in Energy Saver, make the "computer sleep" -> "never".

  3. You don't want your screen is on when you are in bed right? So make "Display sleep" -> some minutes.

  4. Uncheck "Put the hard disk(s) to sleep when possible" and "Restart automatically if the computer freezes".

That should work!

share|improve this answer

You can also temporarily disable sleep from the command line with "caffeinate" regardless of the sleep settings in system preferences.


The basic function of caffeinate when run without any arguments it to prevent active sleep while caffeinate is running:


It will prevent active sleep until you stop caffeinate with "Control + C" or kill all caffeinate processes. After termination the MacBook will resume its normal behaviour (perfect for a computational intensive task)

You can also run caffeinate for a specific pre-determined amount of time to prevent sleeping for that specific amount of time e.g. 4 hours (specify time in seconds) - The ampersand makes the terminal run the process in the background so you continue working.

caffeinate -t 144000 &

Caffeinate can also be attached to other commands to prevent the MacBook from sleeping while the given command is being executed:

caffeinate [command_to_run] -arguments

For a full list of options please refer to the man-page

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.