Stack Engineer

Use Caffeinate to Disable Sleep

You can stop your Mac from going to sleep by using caffeinate to keep it awake.

Disable Sleep Indefinitely

Open the Terminal and run the following command. It will continue to run and keep your mac from going into sleep mode until you press Ctrl-C.

caffeinate

Disable Sleep for a Specific Time Period

Open the Terminal and run the following command. Be sure to change the 10 to the number of seconds you want it to run for. It will keep your mac from going into sleep mode until the number of seconds have elapsed.

caffeinate -u -t 10