← GuidesPower · 4 min read · updated November 24, 2026 · by Dom, who makes Desktop Goods

The caffeinate command: keep a Mac awake from Terminal

How to use macOS's built-in caffeinate command to stop sleep for a set time, while a command runs, or until an app quits.

caffeinate ships with every Mac. It stops the Mac sleeping for as long as it runs.

The basics

Open Terminal and type:

caffeinate -d

The Mac and display stay awake until you press ⌃C.

The useful flags

Flag Prevents
-d The display from sleeping
-i The system from idle sleeping
-m The disk from idle sleeping
-s System sleep (only on AC power)
-u Declares the user active (wakes the display)
-t 3600 Runs for 3600 seconds, then stops
-w 1234 Runs until process 1234 exits

Recipes

Keep awake for two hours:

caffeinate -d -t 7200

Keep awake while a command runs:

caffeinate -i rsync -a ~/Photos /Volumes/Backup

Keep awake until an app quits (find its process ID first):

caffeinate -i -w $(pgrep -x "Final Cut Pro")

Without Terminal

If you’d rather click than type, Vigil does the same from the menu bar: 15 minutes, 1 hour, 3 hours, forever, or until an app quits, with the time left counting down. Free alternatives: Amphetamine and KeepingYouAwake. Compare: best keep-awake apps.

Try it right here

Vigil, live in your browser

This is the real interface. Click around. If it fits, it's yours for $4.99 once, with free updates.

Exporting “Wedding film final.mov”
4K · 38 min
41%About 52 minutes left
Export stops if your Mac goes to sleep.
Display sleeps in 0:08
Your Mac went to sleep.The export stopped at 41%. Click to wake it.
VigilOff
AWAKE FOR ANOTHER1:00:00
Keep awake for
Try it: wait, then keep it awake

Related