MacOS was developed to be a highly stable and power-efficient operating system. When it detects the ability to save power by turning the display off or going to sleep, it will. But sometimes you don’t want to make to go to sleep. If only you could give it a cup of coffee.
Caffeinate is a Terminal command that will keep your Mac awake
To use it, navigate to Terminal by going to Applications > Utilities > Terminal.
Then, type and hit return:
caffeinate
That’s it. As long as that command is running, your Mac won’t go to sleep.
To end the process, click inside the Terminal window, and press Command ⌘ + W. A sheet will ask you if you would like to end the processes. Click Terminate.
You can also specify to run caffeinate for a specific period of time. Just use -t followed by the number of seconds. For example, to stay awake of an hour use (60 times 60):
caffeinate -t 3600
Your Mac will stay awake for that period of time and then resume normal operation.