How to prevent Mac from going to sleep

Want to leave your Mac on for a while for some process to finish? The default behavior in OS X is to put the computer into a low power sleep mode after a couple of minutes of inactivity. While this is great for saving energy, you may find it interfering with your computer usage.

Permanent solution

Open System Preferences, and go to Energy Saver section.  Here you see two sliders for Computer Sleep and Display Sleep. The sliders range from 1 minute, to Never. Use the sliders to adjust the sleep behavior to suit your needs. If you have a portable Mac, there are separate settings for Battery powered operation and for Power Adapter. You may disable sleep altogether but putting the slider on “Never”, just beware that it will increase your energy usage, and likely cause more wear on the system.

Occasional solution

This handy Caffeine app can prevent your Mac from entering sleep mode on demand. An icon in the menu bar will allow you to toggle the setting for those occasional times when you need to computer to run uninterrupted. Click on the cup to toggle Caffeine. System settings apply when the cup is empty, and Caffeine is working when the cup is full. Very convenient and free.


One time solution

If you are familiar with the command line terminal on Mac, OS X Mountain Lion (10.8) has a great new command just for this purpose. As mentioned on AddictiveTips, the caffeinate command can be used along with a timer set to any length of time you want.

caffeinate -t 3600

Where 3600 is the number of seconds in one hour. You may modify it to any number of seconds, or alternatively just enter caffeinate without a timer to disable sleep mode until that terminal window is closed.