Close ad

Right now I'm uploading several gigabytes of photos to my Google Drive. I'm slowly but surely getting tired of touching the keyboard every 10 minutes to keep the MacBook from going to sleep. I'm too comfortable changing my settings in system preferences, so I decided to try to find an alternative - and I did. If you are in the same or similar situation as I am, there is one terminal command that you might find useful. The feature that keeps your Mac or MacBook "on your toes" is called Caffeinate, and in this tutorial we'll show you how to use it.

How to use the Caffeinate command

  • As a first step, we open Terminal (either using Launchpad and the Utility folder, or click on the magnifying glass in the upper right corner and type Terminal in the search box)
  • After opening the Terminal, just enter the command (without quotes) “caffeinated"
  • The Mac immediately switches to Caffeinated mode
  • From now on, it will not turn off by itself
  • In case you want to quit Caffeinate, press the hotkey Control ⌃ + C

Caffeinated for a time interval

We can also set Caffeinate to be active only for a certain time:

  • For example, I want Caffeinated mode to be active for 1 hour
  • I will convert 1 hour to seconds, i.e. 3600 seconds
  • Then in Terminal I enter the command (without quotes) “caffeinated -u -t 3600(the number 3600 represents the time of active Caffeinate for 1 hour)
  • Caffeinate automatically turns off after 1 hour
  • If you want to end the caffeinated mode earlier, you can do so again using the shortcut Control ⌃ + C

And it is done. With this tutorial, you will never need to reset system preferences again. Just use the Caffeinate command and your Mac or MacBook will never go to sleep on its own again, but will complete whatever tasks you give it.

.