How to keep a Mac awake
InputConfig is completely free on the Mac App Store. You don't have to make an account, there are no subscriptions, and nothing is locked. Optimized for Apple silicon.
The quickest way to keep a Mac awake is the caffeinate command that ships with macOS: type it in Terminal and the Mac stays awake until you close that window. For something permanent, two settings in System Settings decide when the display turns off and whether the Mac sleeps. A free menu bar app such as Amphetamine or KeepingYouAwake puts the same switch one click away.
On this page: 8 sections
Steps
- Open Terminal.
- Type caffeinate -d and press Return.
- Leave the window open for as long as the Mac should stay awake.
- Press Control C in that window to let the Mac sleep again.
- For a permanent change, set Turn display off in System Settings, Lock Screen.
Keep it awake from Terminal
caffeinate is Apple's own tool, and it holds the Mac awake for as long as it runs. Pick the line that fits the job.
Terminal: Keep the display and the Mac awake until you stop it.
caffeinate -dWhat happens: Nothing prints. The Mac stays awake until you press Control C or close the window.
Terminal: Stay awake for one hour, then go back to normal.
caffeinate -d -t 3600What happens: The number is seconds, so 3600 is an hour. The Mac can sleep again when it runs out.
Terminal: Stay awake only while a long command runs, such as a build, a download script or a coding agent.
caffeinate -i your-command-hereWhat happens: The Mac cannot idle sleep while that command runs, and the hold ends by itself when the command finishes.
- -d. Keeps the display from sleeping.
- -i. Keeps the Mac from idle sleep, while the display can still turn off.
- -s. Keeps the whole system awake, and Apple's manual says this one only works on AC power.
- -w and a process number. Holds the Mac awake until that process ends.
For a download or a long job, caffeinate -i with the command is the cleanest way, because it stops by itself.
Change when the display and the Mac sleep
Two places in System Settings decide it, and neither needs an app:
- The display. In System Settings, Lock Screen, set Turn display off on power adapter when inactive, and on battery for a MacBook, to a longer time or Never.
- The Mac itself. In System Settings, Battery, Options on a MacBook, turn on Prevent automatic sleeping on power adapter when the display is off. On a desktop Mac the setting reads Prevent automatic sleeping when the display is off.
- The screen saver. Start Screen Saver when inactive is on the same Lock Screen page, and it can lock the Mac even when it is awake.
The display setting and the sleep setting are separate, so set both if the Mac must keep working with the screen dark.
Keep a MacBook awake with the lid closed
A MacBook sleeps when you close the lid, and caffeinate does not change that. Apple's closed-display mode keeps it running with the lid shut when three things are true:
- It is on power. The MacBook must be plugged in, not on battery.
- An external display is connected. The Mac moves its picture to that screen.
- An external keyboard and mouse or trackpad are connected. You need a way to use it with the lid shut.
Amphetamine's App Store listing also offers keeping a MacBook awake with the lid closed. KeepingYouAwake's own page says it only prevents sleep with the lid open. Without a display and power, a closed MacBook sleeps whatever an app says.
Use a free menu bar app instead
- Amphetamine. It is free on the Mac App Store, and its listing says there are no in-app purchases. It has timers, triggers, and an option to move the pointer now and then.
- KeepingYouAwake. It is free and open source under the MIT license, and it is a small wrapper around caffeinate. Install it from its GitHub page or with Homebrew.
Terminal: Install KeepingYouAwake with Homebrew.
brew install --cask keepingyouawakeWhat happens: A cup appears in the menu bar. Click it to keep the Mac awake, and click again to let it sleep.
If the Mac still goes to sleep
Climb this ladder, smallest step first:
- Check the window is still open. caffeinate only holds the Mac while it runs, so closing Terminal ends it.
- Check the lid. A closed MacBook needs power, a display and a keyboard and mouse.
- Check the battery. caffeinate -s only works on AC power.
- Check the screen saver. A locked screen is not sleep, and Start Screen Saver when inactive can lock it anyway.
The short version
- For now. Type caffeinate -d in Terminal and leave it open.
- For one job. Type caffeinate -i before the command.
- For good. Change Lock Screen and Battery in System Settings.
- One click. Amphetamine or KeepingYouAwake in the menu bar.
If you came here for a mouse jiggler, a mouse jiggler for Mac covers what it does and the free ones. On a Mac, caffeinate does the job a mouse jiggler is usually bought for.
Questions
How do I keep my Mac awake without an app?
Open Terminal and type caffeinate -d. The Mac stays awake until you press Control C or close the window. For a permanent change, set Turn display off in System Settings, Lock Screen.
How do I keep my Mac awake while a download or a long command runs?
Put caffeinate -i in front of the command. The Mac cannot idle sleep while that command runs, and the hold ends by itself when it finishes.
Can a MacBook stay awake with the lid closed?
Yes, in Apple's closed-display mode: the MacBook must be on power, with an external display and an external keyboard and mouse or trackpad connected.
Is caffeinate safe?
Yes. It is Apple's own tool, it ships with macOS, and it only asks the system not to sleep. Closing its window or pressing Control C ends it.
Related
This page in other languages: Deutsch, Español, Français, 日本語, Português, Tiếng Việt
Completely free. You don't have to make an account, there are no subscriptions, and nothing is locked. Optimized for Apple silicon. Open source on GitHub.
Updated