Does your Mac go to sleep at inopportune times? Would you like to keep it awake, but don’t want to install additional software? With this tiny little command line trick, you can keep your Mac awake for a specified durations or indefinitely.
In the past we’ve told you that you can use a handy little app called Caffeine to keep your Mac awake. Caffeine is great because it has been around awhile, it’s free, and it just plain works. But, you may not want to install and run an application for such a simple function, which can be accomplished just as easily from a Terminal window.
To open the Terminal, you can either open the Applications > Utilities folder and double-click it from there, or invoke Spotlight with Command+Space and search for it.
Once the Terminal is open, simply type
caffeinate, press Enter, and your Mac will stay awake for as long as you leave the Terminal running. You can minimize or hide it, and your Mac will not go to sleep until you use the keyboard shortcut Ctrl+C to interrupt the command.
Okay, that’s great, but the Caffeine application allows you to set how long the computer stays awake. What about using the Terminal method?
No problem, the Terminal can do that too. In fact, unlike Caffeine, you can choose any duration you like, not just a specific duration from a list. In this case, we’ve specified we want to add a duration using the switch
-t plus time in seconds. In this case, we’re allowing the computer to stay awake for 3600 seconds (or one hour).
We’ve added an ampersand (
&) to the end of the argument so that the command runs in the background. Using
& allows us to continue to use the terminal while the
caffeinate command runs in the background.
There are other arguments you can apply to the
caffeinate command as well.
To prevent the display from sleeping, use
caffeinate -d. To prevent the system from idle sleeping, use
caffeinate -i. If you want to prevent the disk from going idle then you want to use the “caffeinate -m” command.
Finally, and this one is particularly useful for laptop users, if you want keep your system awake while it is plugged into AC power, use
Of course, if you don’t want to use the command line, you can always change the sleep timeout in the Energy Saver preferences.
However, this isn’t exactly the most convenient method if you want to make easy sleep changes on the fly.
So, there you have it, keeping your Mac awake is just that simple. You can either use the Caffeine app, the
caffeinate command, or adjust the Energy Saver settings. Whatever method you decide to use, we’re sure you’ll find it easy to keep your Mac from sleeping.
- › How to Use Marks in OS X’s Terminal for Easier Navigation
- › How to Temporarily Prevent Your Mac from Sleeping
- › How to Use a Screensaver as Your Background on OS X
- › The Best “Just For Fun” Tricks Hidden in macOS’ Terminal
- › Top 10 Terminal Tricks in macOS
- › The New Fire TV Cube Has Two HDMI Ports and Wi-Fi 6E
- › How to Restart a Samsung Galaxy S21
- › New Eero Wi-Fi Hardware Is Ready to Steal Ubiquiti’s Thunder