How do I prevent my MacBook from sleeping when downloading apps from the App Store

When I try to download large apps from the App Store whether on battery or AC power the displays turns off after time set and downloading also stops.

The Energy Saver preferences are set to defaults.

What should I do to continue download even when display is off?

I am using OS X 10.9.4


Solution 1:

If you don't want to install any software or change settings, you can use the Terminal utility caffeinate. Open Terminal (located in /Applications/Utilities/), type in caffeinate, and press return ↩︎.

If you want to set a timeout so it will go to sleep after some amount of time, use this:

caffeinate -t 3600

That will make it stay awake for an hour. (3600 is the number of seconds you want it to stay awake.)

To stop or cancel the caffeinate command, press ^ ControlC.

Solution 2:

You could set hot corners. Push the cursor to that corner & it won't nod off.

That would save you having to change the regular policy, for the times you do want it to sleep after being idle.

enter image description here

Solution 3:

you can use caffeinate -w <the Process ID of the download> for this.

  • caffeinate command makes your computer unable to fall asleep (although your display may),

  • the -w option makes it wait for a process to finish and before then your computer cannot fall sleep, which is exactly what you wanted to do.

to do so you can first find the Process ID(PID) for your download with Activity Monitor, then open up Terminal(bash) and type in for example caffeinate -w 4708, replace the number with the PID you found.

  • be careful with a low PID number as it may be a system process, in which case your computer may run on until the battery dies.

  • also if you plan on using this command often on certain processes, you may want to use caffeinate -w $(pidof <name of process>) instead, this will find the ID of the process you name each time (as PID is assigned by the system and will change each time you run it)

the advantage this has over

  • changing system preferences: it doesn't require you to change the preference back once you're finished

  • caffeinate -t <number of seconds>: your download may not finish in a certain amount of time, in that case the goal is not achieved; or it may finish really quickly, in that case you would be wasting energy.