Keep your Mac from sleeping in Mountain Lion

Aug 01, '12 07:30:00AM

Contributed by: kirkmc

Since Mountain Lion was released, I find that my Macs go to sleep when I don't want them to. I had my Energy Saver preferences set to 15 minutes, but I've noticed that when something is active, such as a download, they got to sleep after 15 minutes, rather than continue with the download. This is not only incorrect behavior, but it's very annoying. What's worse, when I changed the setting to Never, they would still go to sleep during long downloads.

The Ask Different blog pointed out that there is a new command in Mountain Lion called caffeinate. This keeps the system awake, or, as the man page says, "prevent the system from sleeping on behalf of a utility."

Run it as follows in Terminal:

caffeinate -u -t 3600
3600 in the above command is the number of seconds to keep the system awake. What's interesting is that you can effectively set your Mac to shut down at a specific time (that is, the built-in sleep mechanism will start counting when that time runs out). You can also run the command alone to keep your Mac awake until you stop it by pressing Control-C.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20120801003744629