Tech Hacks, News and Tutorials

How to Prevent Mac from Sleeping

Similar to what happens with our iPhone or iPad, the Mac has three states of activity. Off, on or at rest. In fact, if we went into details there are various degrees and types of rest, from a screen shutdown to a disk shutdown or deep sleep. When we are using our Mac it is on and sometimes, especially if we perform actions in the background, while we are away from the computer it is necessary that it does not go to sleep.

Terminal, our ally

If we talk about preventing Mac from going to sleep there are many third-party apps inside and outside the Mac App Store that fulfill this function. It is important to say that some do it better than others but in general they all achieve their goal. However, and especially with the intention of reducing dependence on third-party apps, we can use Terminal to achieve the same goal.

Among the advantages of using Terminal we have:

  • It will work on any Mac we use.
  • Resource consumption is minimal.
  • Security is maximum.

How to Prevent Mac from Sleeping

Step 1. Open Finder. Go to the Applications tab and open System Preferences.

Step 2. Then click on the Energy Saver option.

Step 3. Then select the Power Adapter option.

Step 4. Click on “Prevent computer from sleeping automatically when the display is off” option.

Step 5. Or, you can also drag the slider to control the display’s sleep to Never.

How to prevent Mac from going to sleep

Command

Like all Terminal based tutorials, we will open it first. We can find the app in the Others folder inside the Applications folder or use Spotlight (Command (⌘) + Spacebar).

Then we will copy and paste the following command (without quotes): “caffeinate -ids” and press Enter (↩︎).

We will see that the Terminal window is executing the command, now we simply minimize it with the peace of mind that our Mac will stay awake.

What does this command mean

What does this command mean

If we are curious about why we have to write this strange command and no other, I will give you a brief explanation :

  • The “caffeinate” part is the command itself and tells the Mac that we want to ask it not to sleep.
  • The “i” stands for “idle” and prevents the Mac from going to sleep due to inactivity.
  • The “d” tells the Mac not to turn off the screen.
  • And the “s” indicates that the system is not sleeping either.

A simple explanation, right? And by the way, if we want the Mac to be able to fall asleep after a certain period of time, we will use “caffeinate -idst X” where X is the seconds after which the Mac will turn off this command and go to sleep.