Need your Mac to stay awake? Open Terminal and type:
caffeinate
That's it. Your Mac won't sleep until you press Control+C to stop it.
No apps to install. No settings to change. One word.
What Caffeinate Does
The caffeinate command prevents your Mac from going to sleep, dimming the screen, or starting the screensaver. It's built into macOS - nothing to download.
Your Mac thinks it's busy doing something important, so it stays awake.
When you're done, press Control+C in the Terminal window. Your Mac goes back to its normal sleep schedule immediately.
Keep It Awake for a Specific Time
If you know how long you need, add a timer. This keeps your Mac awake for one hour (3600 seconds):
caffeinate -t 3600
After an hour, it stops automatically. You don't have to remember to turn it off.
Common times:
- 30 minutes:
caffeinate -t 1800 - 1 hour:
caffeinate -t 3600 - 2 hours:
caffeinate -t 7200 - 8 hours:
caffeinate -t 28800
Keep It Awake While a Command Runs
This is the most useful trick. You can tell caffeinate to keep your Mac awake while another command is running:
caffeinate -i your-command-here
For example, if you're downloading a large file:
caffeinate -i curl -O https://example.com/huge-file.zip
Your Mac stays awake until the download finishes, then goes back to normal sleep behavior.
This works with any command. Backups, file copies, software installs - anything.
The Different Flags
Caffeinate has a few options for what kind of sleep to prevent:
| Flag | What it prevents |
|---|---|
-d |
Display sleep (screen stays on) |
-i |
Idle sleep (system won't sleep from inactivity) |
-m |
Disk sleep (hard drives stay spinning) |
-s |
System sleep (keeps everything awake, even on battery) |
-u |
Declares user activity (like moving the mouse) |
The plain caffeinate command with no flags uses -i by default, which prevents idle sleep.
If you need the screen to stay on (for a presentation, maybe), use:
caffeinate -d
You can combine flags:
caffeinate -di
That prevents both display sleep and idle sleep.
Common Mistakes
Closing the Terminal window kills it. If you close the Terminal window or quit Terminal, caffeinate stops. Your Mac can sleep again. Either keep the window open or use the -t timer option.
Forgetting it's running. If you leave caffeinate running and walk away, your Mac stays awake forever. That drains battery on a laptop. Use the timer if you might forget.
Using -s on battery power. The -s flag prevents sleep even when on battery. This will drain your battery completely if you forget about it. Only use -s when plugged in.
Check If Caffeinate Is Running
To see if caffeinate is currently active on your Mac:
ps aux | grep caffeinate
If you see a line with caffeinate (not just the grep command), it's running.
To kill all running caffeinate processes:
killall caffeinate
When to Use This
- Long downloads - Keep your Mac awake until the file finishes
- Presentations - Screen won't dim while you're talking
- File transfers - Large backups or copies won't get interrupted
- Running scripts - Long processes can complete without interruption
- Video calls - Combine with
-dso your screen doesn't dim mid-call
Compared to Clicking Around in Settings
You can do this in System Settings too. Go to Displays > Advanced and adjust sleep timers. But that changes your settings permanently until you change them back.
Caffeinate is temporary. It overrides your settings while it runs, then your Mac goes back to normal automatically. Nothing to remember to undo.
Keep Learning
That's one command. There are dozens more that make your Mac easier to use. If you want to learn Terminal from scratch, check out the free 9-module course at Mac Terminal for Humans.