---
title: "caffeinate: keep your Mac awake from Terminal · Kilobat Guides"
url: "https://kilobat.app/guides/caffeinate-keep-mac-awake"
description: "Use the built-in caffeinate command to stop a Mac from sleeping during a download, build or script, and see which apps keep it awake."
---

Sleep and power

# Keep a Mac awake from Terminal with caffeinate

The `caffeinate` command stops a Mac from sleeping while a task runs. It is part of macOS and changes no settings.

Applies to: All current macOS versions. The System Settings paths are for macOS 13 Ventura and later. · Checked: 29 October 2026

## Symptoms

- A download, build or script stops when the Mac goes to sleep.
- A remote session or SSH connection drops after some minutes with no input.
- You want the Mac to stay awake for one task, but you do not want to change the sleep settings.

## Likely causes

- **Idle sleep.** macOS puts the Mac to sleep after a time with no keyboard or mouse input. Network activity alone does not always stop this.
- **Display sleep.** The display turns off on its own timer. On some Macs, the system then sleeps too.
- **The lid.** Closing the lid of a Mac laptop puts it to sleep. `caffeinate` does not change this. See [Keep a Mac laptop working with the lid closed](https://kilobat.app/guides/clamshell-lid-closed-mac).

## How to check

1. Open Terminal. See which processes now prevent sleep.

   ```
   pmset -g assertions
   ```

   Output A list of assertions such as `PreventUserIdleSystemSleep`, with the process that holds each one.
2. See the sleep settings that are in use now.

   ```
   pmset -g
   ```

## How to fix it

1. To keep the Mac awake while one command runs, put `caffeinate -i` before the command. The assertion stops when the command stops.

   ```
   caffeinate -i make
   ```
2. To keep the Mac awake for a fixed time, give the time in seconds with `-t`. This example is two hours.

   ```
   caffeinate -i -t 7200
   ```
3. To keep the Mac awake until a process stops, give its process ID with `-w`.

   ```
   caffeinate -i -w 12345
   ```
4. To keep the display on too, add `-d`.

   ```
   caffeinate -d -i
   ```
5. To stop `caffeinate` that you started with no command, press Control-C.
6. To stop automatic sleep while the display is off, change the setting. On a Mac laptop, choose Apple menu > System Settings > Battery > Options. Turn on “Prevent automatic sleeping on power adapter when the display is off”.
7. On a Mac desktop, choose Apple menu > System Settings > Energy. Turn on “Prevent automatic sleeping when the display is off”.

## With Kilobat

1. Kilobat can keep the Mac awake until a download goes quiet, then let it sleep. Open Kilobat from the menu bar. Click the teacup and choose Until Downloads Finish.
2. The CLI does the same. It stops after 3 minutes below 16 KB/s.

   ```
   kilobat awake --until-quiet
   ```
3. To keep the Mac awake while one command runs, and to see the data it moved, use `awake --`.

   ```
   kilobat awake -- make release
   ```
4. These features are free. See [the recipe](https://kilobat.app/guides/recipes/keep-mac-awake-download) for the app, CLI and MCP steps.

## Questions

**Does caffeinate keep the Mac awake with the lid closed?**

No. `caffeinate` stops idle sleep. Closing the lid still puts a Mac laptop to sleep, unless the Mac uses an external display, keyboard and power. See [Keep a Mac laptop working with the lid closed](https://kilobat.app/guides/clamshell-lid-closed-mac).

**What does the -s option do?**

`-s` stops system sleep. The man page says that it works only when the Mac is on AC power.

**Does caffeinate change my settings?**

No. It creates power assertions. They stop when `caffeinate` stops.

## Sources

- caffeinate(8), man page installed with macOS 27.2
- pmset(1), man page installed with macOS 27.2
- [Apple Support: Set sleep and wake settings for your Mac](https://support.apple.com/guide/mac-help/prevent-your-mac-from-sleeping-mchle41a6ccd/mac)

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with `man <name>` in Terminal.

## Related guides

- [Keep your Mac awake until a download finishes](https://kilobat.app/guides/recipes/keep-mac-awake-download): Kilobat keeps the Mac awake while transfers run.
- [Mac sleep stops downloads](https://kilobat.app/guides/mac-sleep-stops-downloads): A Mac that goes to sleep stops most app activity, so a long download can stop or fail.
- [Keep a Mac laptop working with the lid closed](https://kilobat.app/guides/clamshell-lid-closed-mac): Closing the lid puts a Mac laptop to sleep.
