How to keep your Mac awake: caffeinate, apps and settings
By Anjali Singh, maker of Doki · Published 29 November 2026
Your Mac dims, then sleeps, when you haven't touched it for a while. That's annoying during a long download, a build, a presentation, or while Claude Code works through a task. Here are four ways to keep it awake, from a one-line command to a menu bar app, and when each one fits.
The short answer
Open Terminal and run caffeinate -d. Your Mac and its screen stay awake until you press Control-C. For a switch you can click instead, use a free menu bar app such as Amphetamine or KeepingYouAwake. None of these keep a MacBook awake with the lid closed on their own.
The four ways, side by side
| Way | How you turn it on | Timers and rules | Cost | Best for |
|---|---|---|---|---|
1. caffeinate | A Terminal command | Yes, with flags | Free, built in | One task, or scripts |
| 2. macOS settings | System Settings | No | Free, built in | A Mac that should never sleep |
| 3. Amphetamine | Menu bar app | Yes, many | Free | Fine control and triggers |
| 4. KeepingYouAwake | Menu bar app | Simple durations | Free, open source | A lightweight on/off switch |
1. The caffeinate command (built in)
Every Mac has caffeinate. Open Terminal (press ⌘ Space, type Terminal) and run one of these:
caffeinate -d: keeps the screen on, so the Mac stays awake too.caffeinate -i: keeps the Mac running but lets the screen turn off. Good for downloads and builds.caffeinate -t 3600: stays awake for an hour (3,600 seconds), then stops by itself.caffeinate -i npm run build: stays awake only while that command runs.
It keeps going until you press Control-C or close the Terminal window. Nothing to install, but you have to remember it's running.
2. macOS settings
If a Mac should never sleep, for example one that runs jobs while plugged in:
- Screen: System Settings, then Lock Screen, and set "Turn display off when inactive" (on power adapter) to Never.
- The Mac itself: on a MacBook, System Settings, then Battery, then Options, and turn on "Prevent automatic sleeping on power adapter when the display is off". On a desktop Mac the same setting is under Energy.
These stay on until you change them back, so they're better for a Mac on a desk than for a laptop you carry around.
3. Amphetamine
Amphetamine is a free menu bar app from the Mac App Store and the most capable option. You can keep the Mac awake indefinitely, for a set time, until a set time, or while a particular app is running or a file is downloading. It also has an optional closed-display mode for MacBooks, which needs an extra script and your admin password.
4. KeepingYouAwake
KeepingYouAwake is a small, free, open-source menu bar app. Click its cup to keep the Mac awake, click again to let it sleep, or pick a duration. It's a friendly switch for caffeinate. Install it from its site or with brew install --cask keepingyouawake.
Which one should you use?
- Once in a while, for one task:
caffeinate -ifollowed by the command, so it stops by itself. - A switch you can click: KeepingYouAwake.
- Timers, schedules or "while this app is open": Amphetamine.
- A Mac that should never sleep: the macOS settings.
Questions
How do I keep my Mac awake without an app?
Run caffeinate -d in Terminal. Use caffeinate -i to keep the Mac running but let the screen turn off.
Can I keep a MacBook awake with the lid closed?
Not with caffeinate or most keep-awake apps on their own. A MacBook stays awake with the lid closed when it's plugged in and connected to an external display, keyboard and mouse. Amphetamine's closed-display mode is the other route.
Is it bad to keep my Mac awake all the time?
It uses more power and battery, and a screen left on shows the same image for hours. Keep it awake for as long as a task needs, then let it sleep.
Does keeping the Mac awake help Claude Code?
Yes, for long tasks. If your Mac sleeps, a running Claude Code session pauses until you wake it. Keep the Mac awake, and set up a notification for when Claude Code finishes so you know when to come back.