There are bound to be times when you would like your OS X Mountain Lion Mac to not go to sleep. You can set you Mac to Never sleep in the System Preferences, Energy Saver preferences pane, but that’s not always going to work. Even when it’s set to Never, your Mac may still, in fact, go to sleep. The other problem with the Energy Saver preference is that you only have the ability to set the sleep action to hold of foor three hours, or never. What if you wanted to keep it from sleeping for four hours? Or four and a half hours? Or eight hours?
With a neat little Mountain Lion-only Terminal command, you can set it to whatever you like. Here’s the scoop.
Launch Terminal app, and then type or paste the following command in:
caffeinate -u -t 14400
The number above can be set to any value, as it’s the number of seconds you’d like your Mac to stay awake. You might want to set it to four hours if, for example, you have a large download to take care of, or a huge render in Final Cut Pro or something. Your Mac will not engage the sleep preferences set in the Energy Saver preference panel until the length of time you’ve set for
caffeinate is finished.
You can run the command by itself, as well. Just type or paste
into a Terminal window and hit return on your keyboard. When you want to manually stop your Mac from staying awake, go to the Terminal window you entered the
caffeinate command and type Control-C on your keyboard to stop the process.
- Source Macworld Hints