Preventing Mac from entering power-saving mode
There are cases where background tasks need to be running on a Mac, such as when certain programs or file transfers need to be constantly active.
In such situations, when the user is not directly controlling the Mac for a certain period of time, there are various constraints, such as the Mac entering sleep mode or the user getting logged out.
If you are a user who frequently performs background tasks, you can simply disable features like sleep mode and screen saver lock screen. However, if you occasionally need to perform background tasks, the settings can be ambiguous.
In such cases where power-saving mode is not necessary, you can prevent it for a certain period of time using terminal commands, and in some cases, you can configure the Mac to keep running with just the display turned off.
“caffeinate” command to prevent Mac from entering power-saving mode
The “caffeinate” command, which seems like it has to work hard, is a built-in macOS command that allows you to prevent power-saving mode using various options.
To use the command, you need to use the Terminal app. You can select the Terminal from Launchpad or search for it using Spotlight and then run it.
Preventing Power Saving Mode
When you enter this basic command in the Terminal, it prevents the Mac from entering power-saving mode while still allowing the screen to turn off.
To stop preventing power-saving mode, you can either close the Terminal or press command + c to stop the command.
caffeinate -t 3600
You can use the
-t argument to prevent power-saving mode for a specific duration of time.
The time value following the argument is in seconds, so you can input the desired time by multiplying minutes by 60.
Turning off Display and Preventing Power Saving Mode
Even when using the power-saving mode prevention command, the default behavior of macOS is to turn off the specified display. To prevent both power-saving mode and display turning off, use the
Preventing Power Saving Mode During Specific Process Execution
caffeinate -i process
By using the
-i argument, you can prevent power-saving mode until a specific process is completed.
This can be useful when compiling code or running custom scripts that require specific actions by the user.
If you want to explore more options for preventing power-saving mode using different arguments, you can enter the above command in the Terminal to check the detailed manual.
The “caffeinate” command will stop functioning when you close the Terminal window, but if you need it again in the future, you can simply open the Terminal and enter the command. If you frequently require this functionality, you may consider using the “Amphetamine” app, which prevents your Mac from sleeping.