MainspringGuides › Keep Mac Awake
macOS Guide

Keep your Mac awake during a long build or render

Updated July 2026 · 3 min read

A clean build, a video export, a Blender render — the kind of job you start and step away from for coffee. Come back to find the Mac asleep and the job frozen where it stood, and you've lost twenty minutes for nothing. The reliable fix is to run the job through caffeinate: it keeps the machine awake for exactly as long as the work runs, then lets go automatically.

Run the job under caffeinate

Instead of asserting wakefulness separately and hoping the timing lines up, hand your build command straight to caffeinate. It holds off idle sleep while the command runs and releases the moment it exits — success or failure.

# Xcode build, awake until it finishes
caffeinate -i xcodebuild -scheme MyApp

# A Makefile target
caffeinate -i make release

# An ffmpeg export
caffeinate -i ffmpeg -i in.mov -c:v prores out.mov

The -i flag stops idle system sleep, so the CPU and GPU keep grinding. The display is still allowed to sleep — the render doesn't care whether the screen is on, and letting it darken keeps the machine cooler and quieter. No timer to guess, and nothing left asserting once the build is done.

Attach to an export that's already running

The build's been going for ten minutes in an app like Final Cut or Compressor before you remember about sleep — no need to cancel and restart. Point caffeinate at the running process and it waits for that specific job to exit with -w.

# Find the render process id
pgrep -fl Compressor
# Keep awake until that process exits
caffeinate -i -w 5120

The -w flag takes a process ID and holds the assertion until that PID is gone. It's the rescue move for a job you didn't launch from the command line — grab its PID with pgrep or Activity Monitor, and caffeinate babysits it to the end.

Make it automatic for every build

If long builds are a daily thing, stop remembering to type caffeinate at all. Add a shell alias so a single word wraps whatever you run.

# Add to ~/.zshrc, then: awake make release
alias awake='caffeinate -i'

Now awake make release or awake npm run build keeps the Mac up for the duration of any command you prefix. It's a small habit that quietly removes a whole category of "why did that fail overnight" mysteries.

What to know before you rely on it

One toggle, no alias to remember

If the Terminal isn't where you live, Mainspring's Keep Awake power-up runs caffeinate for a duration you choose and expires on its own when the render's done — part of 90+ hidden macOS settings it turns into labelled, reversible toggles.

Try Mainspring free →

Signed & notarized by Apple · 1-day free trial · $29 once

Tidy up that alias while you're in there

Adding the awake alias is a good excuse to clean up your shell config. Our guide to customizing your .zshrc on Mac covers aliases, functions, and prompt tweaks that make long-running work smoother.