Sleep-Wake – How to Prevent Mac Sleep from Command Line

command linesleep-wake

I have a long running script at the remote computer.

I don't want terminate my ssh session, and need enter it into a shell script.

How is it possible to prevent my Mac from falling into sleep from the command line?

Best Answer

In Mountain Lion you can use the caffeinate command.

caffeinate -u -t 1000

will prevent idle sleep for 1000 seconds.