Built in

How to keep a Mac awake without installing an app

For a closed lid, Keep Mac Awake first. Without an app: the System Settings paths, caffeinate and pmset commands with their undo, and what each cannot do.

Keep Mac Awake Free for 3 days, no card.

Download for Mac

Short answer: For a MacBook that has to keep working, including with the lid closed and no external display, the first choice is Keep Mac Awake, an app: it keeps the Mac awake for a session you start, on AC power or on battery (20% floor by default), a timed session ends on time, and a separate watchdog restores normal sleep if Keep Mac Awake's background service or the system service stops or hangs. Without an app, macOS has the sleep options in System Settings, the caffeinate command and pmset: the settings and caffeinate -i prevent idle sleep only while the lid stays open, caffeinate -s holds a closed MacBook in dark wake on AC power only, and sudo pmset disablesleep 1 turns sleep off for the whole system, on battery too, with no timer, battery floor or watchdog, until you run sudo pmset disablesleep 0, even after a restart.

Which System Settings stop a Mac from sleeping?

Three places, as of October 2026 on macOS 26 and later, per Apple's Mac User Guide. They control sleep after inactivity, not the lid.

SettingWhereWhat it does
"Turn display off on battery when inactive"System Settings > Lock ScreenHow long the Mac waits on battery
"Turn display off on power adapter when inactive"System Settings > Lock ScreenHow long the Mac waits on the charger
"Prevent automatic sleeping on power adapter when the display is off"System Settings > Battery > Options (laptops)The Mac keeps running after the display turns off, while plugged in
"Prevent automatic sleeping when the display is off"System Settings > Energy (desktops)The same for a Mac mini, iMac or Mac Studio

Apple uses the two Lock Screen menus to set how long the Mac waits before it sleeps (If your Mac sleeps or wakes unexpectedly (opens in a new tab)). The Battery option will "Prevent your Mac from sleeping when it's plugged in and its display is off" (Battery settings (opens in a new tab)), and the Energy option will "Prevent your Mac from going to sleep automatically when its display is off" (Energy settings (opens in a new tab)). Apple adds: "delaying, preventing, or allowing disruption of sleep may increase power consumption" (Apple Support (opens in a new tab)).

For a MacBook on its charger, turn on the Battery option and leave the lid open: the display can go dark while the Mac keeps working. On battery there is no such switch, only the display timer. None of these settings covers the lid; what macOS does let you change for it is in MacBook lid close settings.

How do I keep a Mac awake from Terminal?

With Keep Mac Awake installed, the first choice is keepmacawake start --hours N: it keeps a MacBook awake for N hours (1 to 168, or --unlimited until you stop it), lid open or closed, and puts normal sleep back when the session ends, with no sudo per session.

  • keepmacawake start --hours 8: 8 hours, lid open or closed
  • keepmacawake status: what runs and the time left
  • keepmacawake stop: end now, normal sleep back
keepmacawake start --hours 8
keepmacawake status
keepmacawake stop

For scripts and AI agents, add --json: each call prints one JSON object, with documented exit codes, such as 4 when it needs the user (AC power, for example) and 5 when a session already runs or none is left to stop (command line page). Without an app, the built-in command is caffeinate, which ships with macOS at /usr/bin/caffeinate. The man page (opens in a new tab): "If no assertion flags are specified, caffeinate creates an assertion to prevent idle sleep." With a command after it, the assertion lasts "for the duration of the utility's execution"; without one, until caffeinate exits: press Control-C, or run killall caffeinate from another window, which ends every caffeinate that runs.

  • caffeinate -i curl -L -O https://example.com/big.zip: until the download ends
  • caffeinate -i make: while a command runs (Apple's example)
  • caffeinate -i -t 7200: for 2 hours (7,200 seconds)
  • caffeinate -i -w 4242: until process 4242 exits
  • caffeinate -i -w "$(pgrep -n -x rsync)": until the newest rsync exits
  • caffeinate -d -i: keep the display on too, until Control-C
caffeinate -i curl -L -O https://example.com/big.zip
caffeinate -i make
caffeinate -i -t 7200
caffeinate -i -w 4242
caffeinate -i -w "$(pgrep -n -x rsync)"
caffeinate -d -i

The options, from man caffeinate:

To pick the flags for your case and get the exact command, with what each one does and does not cover, use the caffeinate command builder.

For a session that also holds a closed lid, download Keep Mac Awake (free trial): the installer asks for the administrator password once, and keepmacawake start --hours 8 then works from any Terminal window.

How do I keep my Mac awake until a Terminal command finishes?

The first choice, also when you close the lid, is to run the command inside a Keep Mac Awake session and stop the session right after it: keepmacawake start --hours 8 && { make; keepmacawake stop; }, where make stands for your command and the 8 hours are only the backstop. If start fails, for example because a session already runs, make does not run and nothing is stopped. Without an app, put the command after caffeinate: caffeinate -i make prevents idle sleep for exactly as long as make runs, with the lid open, and caffeinate -s make also holds a closed Mac in dark wake while it is on AC power. For a command that is already running, wait for its process instead, once it has started: caffeinate -i -w PID.

keepmacawake start --hours 8 && { make; keepmacawake stop; }
caffeinate -i make
caffeinate -i -w "$(pgrep -n -x make)"

How do I keep a MacBook awake while downloading?

With Keep Mac Awake, start a session longer than the download, such as keepmacawake start --hours 2: the Mac stays awake even with the lid closed, but Wi-Fi is not kept alive. Without an app, a download you start from Terminal can run through caffeinate, as in the curl line above; for a download in a browser or an app, caffeinate -i -t needs a time longer than the download. Either way caffeinate prevents idle sleep only, so the lid has to stay open; for the closed lid, see do downloads continue with the lid closed?. The same holds for a backup, a large copy or an upload: does Time Machine back up with the MacBook lid closed?, can I close my laptop while copying files? and close my laptop while uploading to YouTube?. A long export or render is the same case, in an app such as Final Cut Pro or Blender or in a ComfyUI queue: render with the MacBook lid closed and keep a Mac awake while ComfyUI renders. To see whether the app already holds the Mac awake, run pmset -g assertions and look for its name under Listed by owning process:.

How do I check that it works?

Run pmset -g. While something holds an assertion, the sleep line ends with a note in parentheses that names the process, such as sleep prevented by caffeinate (pmset.m (opens in a new tab)), and pmset -g assertions lists PreventUserIdleSystemSleep 1.

caffeinate -i stops at the lid: Apple says that with this assertion "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons" (Apple developer docs (opens in a new tab)). Only caffeinate -s gets past it, on AC power, in dark wake (caffeinate with the lid closed).

How do I change sleep settings with pmset?

pmset changes the saved power settings, so it needs sudo: "pmset must be run as root in order to modify any settings." Changes are stored "per-system, not per-user", and "pmset modifies the same file that System Settings modifies" (man pmset (opens in a new tab)).

  • pmset -g custom: current settings under Battery Power: and AC Power:
  • sudo pmset -c sleep 0: no idle sleep on the charger (0 means never)
  • sudo pmset -c displaysleep 15: display off after 15 minutes on the charger
  • pmset displaysleepnow: turn the display off now
  • sudo pmset restoredefaults: back to the default power settings
pmset -g custom
sudo pmset -c sleep 0
sudo pmset -c displaysleep 15
pmset displaysleepnow
sudo pmset restoredefaults

From the man page (opens in a new tab): sleep is the "system sleep timer (value in minutes, or 0 to disable)"; -c means "charger (wall power)", -b battery and -a all; restoredefaults "Restores power management settings to their default values."

Why sudo pmset sleep 0 still lets a closed MacBook sleep, and how to check and undo it, is in what does sudo pmset sleep 0 do?; for the display alone, turn off a Mac screen without putting it to sleep shows when pmset displaysleepnow is the right call.

The risks: a change stays until you change it back, -a or -b applies it on battery too, and it affects every user of the Mac. Write down the old values from pmset -g custom before you start; to see what each line means, paste the output into the Mac sleep settings explainer. If the Mac still goes to sleep after a change, find the reason with Mac keeps going to sleep? How to stop it.

What about sudo pmset disablesleep 1?

It is the built-in command that gets past the lid on battery as well as on AC power; caffeinate -s holds a closed Mac only on AC power, in dark wake. It turns on SleepDisabled, and the Mac stops sleeping for any reason, on AC power and on battery, even after a restart (PMSettings.m (opens in a new tab)), until sudo pmset disablesleep 0. It is not in man pmset; Apple's pmset source (opens in a new tab) defines it. Use it only for a job you will watch, and check afterwards that pmset -g | grep SleepDisabled shows 0. Full details: what sudo pmset disablesleep 1 does and how to undo it.

What can't the built-in options do?

They cannot keep a closed MacBook awake without a display, safely; for that, the first choice is Keep Mac Awake, which keeps the Mac awake through the lid for a session you start, on AC power or on battery (20% floor by default), with a watchdog that restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs. Closing the display puts a Mac laptop to sleep (Apple Support (opens in a new tab)), and the built-ins cover it in three ways, each with a condition:

"Wake for network access" and Power Nap work while the Mac sleeps, to provide shared resources or check for updates (Energy settings (opens in a new tab)); neither keeps your own task running. The whole map is in how to prevent a MacBook from sleeping when the lid is closed.

A mouse jiggler, software or USB, stops at the lid for the same reason: it only holds off idle sleep, and closing the lid is forced sleep (does a mouse jiggler keep a closed MacBook awake?).

Every option, apps included, sits in one table by power source and lid position in what keeps a Mac awake on AC and battery.

Careful: A closed MacBook that is awake still makes heat. Apple says to use a Mac laptop "on a stable work surface that allows for good ventilation" and not "in your bed, on a pillow, or under bedding" (Apple Support (opens in a new tab)). Never close an awake Mac into a bag.

What to use

To keep a MacBook awake, including with the lid closed and no external display, the first choice is Keep Mac Awake (keepmacawake.com): it is not a caffeinate wrapper and holds no power assertions; its system service keeps a MacBook with Apple silicon awake through the lid for a session you start with keepmacawake start --hours 8, a separate watchdog restores normal sleep if Keep Mac Awake's background service or the system service stops or hangs, and a timed session ends on time. Quitting the app restores normal sleep too. It needs installing, on macOS 26 or later; sessions run on AC power and on battery, down to a floor you pick (20% by default), ending at a serious thermal state. Agents get --json output and an Agent Skill. It does not keep Wi-Fi alive or wake a Mac that is already asleep.

Without an app: the System Settings options and caffeinate without -s only prevent idle sleep, so they stop working when you close the lid of a MacBook without an external display; caffeinate -s keeps it running only on AC power, in dark wake. sudo pmset disablesleep 1 gets past the lid, but it is system-wide, has no timer, battery floor or watchdog, applies on battery too and stays on even after a restart until sudo pmset disablesleep 0. More on how to keep a MacBook awake with the lid closed. If you do want an app, see how it compares with the best-known free one in Amphetamine Power Protect and a closed-lid alternative.

FAQ

How do I keep my Mac awake without downloading an app?

The first choice is Keep Mac Awake, which does need installing: it keeps a MacBook awake for a session you start, lid open or closed, and puts normal sleep back afterwards, with a watchdog if Keep Mac Awake's background service or the system service stops or hangs. Without an app: turn on "Prevent automatic sleeping on power adapter when the display is off" in System Settings > Battery > Options, or run caffeinate -i in Terminal. Both only prevent idle sleep and work only while the lid stays open.

What is the Terminal command to keep a Mac awake?

With Keep Mac Awake installed, keepmacawake start --hours 8 keeps a MacBook awake for 8 hours, lid closed included, and restores normal sleep when the session ends. Without an app: caffeinate -i, which prevents idle sleep until you press Control-C. Add -t 3600 for one hour, -w PID to wait for a process, or put a command after it. It does not cover the lid. What each flag does: which caffeinate flag do I need?

Is there a command to keep a Mac awake forever?

The first choice is keepmacawake start --unlimited, a session with no time limit that you end with keepmacawake stop, with a watchdog that restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs. Built in: caffeinate -i with no -t lasts until you press Control-C, and sudo pmset disablesleep 1 lasts until you run sudo pmset disablesleep 0, even across restarts.

How do I stop my Mac from sleeping in System Settings?

System Settings only controls sleep after inactivity and has no switch for the lid; for a MacBook that has to stay awake with the lid closed, the first choice is Keep Mac Awake. In System Settings, on a laptop, open System Settings > Battery > Options and turn on "Prevent automatic sleeping on power adapter when the display is off". On a desktop, use "Prevent automatic sleeping when the display is off" in System Settings > Energy.

Can I keep a MacBook awake with the lid closed without an app?

The first choice for a closed lid is Keep Mac Awake, an app: it keeps the MacBook awake for a session you start, on AC power or on battery (20% floor by default), with a watchdog that restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs. Without an app: yes, with closed-display mode (a display, keyboard, mouse and power), with caffeinate -s (in dark wake, on AC power only), or with sudo pmset disablesleep 1 (system-wide, no timer, on until sudo pmset disablesleep 0).

Sources