macOS is set to sleep mode by default. Sleep mode automatically turns off the screen or switches the machine to sleep mode after a certain period of time, helping to reduce power consumption, extend the battery life of a notebook, or increase the energy efficiency of a desktop.
In this blog post, I will introduce how to prevent sleep mode from automatically switching using the
Caffeinate command is a command that prevents sleep mode from automatically switching in macOS. This command keeps the system active, preventing the screen from turning off or the computer from automatically entering sleep mode.
If you want to prevent the computer from switching to sleep mode when no operation is performed, you can run the command as follows.
caffeinate -d -t 3600
-d: Prevents the screen from turning off.
-t: Sets how long to keep the system active. The above command keeps the system active for 1 hour.
You can see that the computer maintains an active state without switching to sleep mode by running the
Caffeinate command in the terminal and running a time-consuming task in another terminal.
When a time-consuming task is completed, you must terminate the
Caffeinate command. You can terminate the
Caffeinate command by pressing
Ctrl + C in the terminal where the
Caffeinate command is executed, or by closing the terminal where the
Caffeinate command is executed.
Why Use Caffeinate
There is also a way to disable sleep mode in the settings, but it is generally better to keep it enabled because disabling sleep mode can increase power consumption and shorten battery life. If you forget to enable sleep mode after disabling it in the settings, the computer will continue to be used with sleep mode disabled, which can cause problems such as shortened battery life.
Also, in the case of a company computer, settings are forced to turn off the screen automatically when you leave your seat for security reasons.
At this time, if you need to run a time-consuming task (command) temporarily, you can use the
Caffeinate command to prevent sleep mode from automatically switching, and terminate the command after the task is completed to keep the default settings.
Done! We’ve seen how to prevent sleep mode from automatically switching in
macOS using the
Caffeinate command. If you want to prevent sleep mode from automatically switching while keeping the default settings, try using the
Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!
Deku created the applications with Flutter.
If you have interested, please try to download them for free.