This Built-in Tool Prevents Your M1 or M2 Mac from Going to Sleep

Computers go to sleep as a way to save energy and prevent unnecessary wear on your hardware.

You can prevent your M1 or M2 Mac running macOS Monterey from going to sleep with a built-in tool.

Of course, you can also fine-tune this feature in System Preferences > Battery.

But there are times when you might only want to prevent your Mac from sleeping until a certain task is completed. And changing the settings back and forth can be annoying.

There’s an easier way…

When it comes to preventing your Mac from going to sleep, most macOS users immediately think of an app.

Of course, there’s always an app. There is Caffeine which is a free popular option, but there’s also paid options.

What some macOS users don’t know, is that this functionality is built-in into macOS. And it’s been available for the last 10 years or so.

It’s a command line program called caffeinate. What were the chances, right?

Don’t worry about the command line part though. Even a complete noob can use caffeinate. And it completely eliminates the need to install yet another app.

How to use caffeinate to prevent your Mac from going to sleep

NOTE: you don’t need an M1 Mac running macOS Monterey for caffeinate to work. You can follow the same steps using an older Mac running an older version of macOS.

To prevent your Mac from going to sleep using the built-in caffeinate app, all you have to do is to open up the Terminal, type caffeinate and press enter.


If you run the command by itself, you will prevent your Mac from going to sleep as long as the command is active.

You can check if it’s running, using bpytop which can be installed via Homebrew.

ALSO READ HOW TO: Background and Foreground Processes

To stop it you will need to kill the process with ctrl+c while inside the Terminal.

You can also set a sleep timer to caffeinate. For example, if you want to prevent your Mac from going to sleep for an hour you will type in caffeinate -t 3600.

Change the timer ( in this example is 3600 ) to whatever you need. Time is expressed in seconds.

You can also target a specific application. For example, you might want to prevent your Mac from going to sleep while you export a video.

All you have to do is type caffeinate path_to_the_core_of_the_app.

To do this you will have to right click on the app inside the /Applications/ folder, and select Show Package Contents and drag-and-drop the core of the app inside the terminal to get its path ( so you don’t have to type it ).

Hint: the core is usually located in /Contents/MacOS/.

For more fine-tunning, there’s some spcific flags that you can use with caffeinate.

  • -d will prevent the display from going to sleep
  • -i will prevent the system from idle sleeping
  • -m will prevent the disk from going to sleep
  • -s will prevent the machine from going to sleep when plugged in
  • -u replicates a currently active user