Since I upgraded to Mountain Lion, i've the feeling my Mac (early 2008 iMac) goes to sleep randomly when i'm connected through SSH.

It's there a way I can prevent my Mac to go to sleep when i'm connected over SSH ?


Caffeine prevents your Mac from falling asleep. Maybe, it can help you out with your issue too. The sleep isn't at all random, but in fact is set in the Energy Saver system preference as well from the terminal using pmset.

You could use pmset to inspect and change the sleep settings if you have admin rights on the remote.

| improve this answer | |
  • I don't have time to write this as a full answer, but caffeinate is a command-line tool built-in to 10.8 that can also be used to prevent sleep temporarily. – gabedwrds Nov 14 '12 at 15:25

You can manage your computer's power settings through

System Preferences -> Energy Saver

Within this pane, click on the Power Adapter tab, and drag the Computer Sleep slider all the way to the right, so that it is set to "Never." This will force the computer to stay awake 24/7. I have a laptop running 10.5 at my house that I have running as a file/web/home media server configured using these settings (though the preferences nomenclature is different on 10.5, the functionality is the same) and enjoy uninterrupted access - that is unless there's a problem with the node, but that's out of our control. Caffeine and caffeinate will also work as other users have noted, but this is the most up-front and user-friendly way to get this done as it involves a GUI interface and no third-party application.

| improve this answer | |
  • Since i've an iMac, I don't have the Power Adapter tab. – Matthieu Riegler Nov 14 '12 at 20:40
  • Naturally :) sorry about that, bit of an oversight. So, is there no Energy preference pane at all to regulate sleep/wake? – soxman Nov 14 '12 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .