Open Terminal and run caffeinate -i -t 3600 to prevent idle system sleep for one hour. Add -d if you also need the display to stay on. Press Control-C to stop early.
What caffeinate actually does
caffeinate is a command included with macOS. It asks the operating system to prevent particular types of sleep while it runs. It does not move the pointer, click buttons, or change a chat app’s presence rules.
Think about what your task needs before choosing an option. A download may need the computer to remain awake while the display turns off. Reading a reference document or watching a dashboard may also require an illuminated screen.
Pick a command for your task
| Task | Command |
|---|---|
| A one-hour download; screen may turn off | caffeinate -i -t 3600 |
| A 30-minute presentation; screen stays on | caffeinate -di -t 1800 |
| A two-hour upload; screen may turn off | caffeinate -i -t 7200 |
| Prevent idle sleep until you stop it | caffeinate -i |
Paste only the command, then press Return. A quiet Terminal window is expected. Keep it open while the session runs. These are temporary requests, not changes to your saved sleep preferences.
Keep your Mac awake for one hour
- Open Terminal, which you can find with Spotlight.
- Enter the following command and press Return.
- Leave that Terminal session running until the task finishes.
caffeinate -i -t 3600The timeout is measured in seconds: 1,800 is half an hour, 3,600 is one hour, and 7,200 is two hours. Terminal normally shows no progress bar. That is expected; a quiet window does not mean the command failed.
To stop before the hour ends, click the Terminal window and press Control-C. Normal sleep behavior can then resume according to your Mac’s settings.
Choose the right flags
| Option | Purpose |
|---|---|
-i | Prevent idle system sleep. |
-d | Prevent display sleep. |
-t 3600 | Release the request after one hour. |
-s | Prevent system sleep while on AC power. |
For a one-hour session with the screen on, combine the options:
caffeinate -di -t 3600Leaving the screen on uses additional energy. For a task that runs without supervision, keeping only the system awake is often the better fit.
What does caffeinate -d do?
-d requests that the display stay awake. -i requests that the system avoid idle sleep. Combine them as -di when you need both. A background download usually does not need an illuminated display; a presentation or reference screen often does.
Running caffeinate with no flags creates an idle-sleep prevention request. Be explicit with -i or -di so the purpose is easy to recognize when you return to the command.
Keep a command awake until it finishes
You can attach the sleep request to a command instead of estimating its duration. For example, in a project that uses make:
caffeinate -i makeThe request lasts while that command runs. This is useful when a build’s completion time varies. The timeout flag is not used when a utility is supplied, so choose either a timed session or a command-scoped session.
Keep an already-running process awake with -w
If you already started a command, you do not need to restart it under caffeinate. Use -w with its process ID (PID). The awake request ends when that process exits. Apple documents this option in the caffeinate manual; you can also read the installed version with man caffeinate.
- Identify the specific process doing your work. Activity Monitor can show its PID; check the process name before copying the number.
- In Terminal, run the command below, replacing
12345with that current PID. - Keep the Terminal session open. Use a second tab for the assertion check below.
caffeinate -i -w 1234512345 is an example, not a PID to reuse. Process IDs change when an app restarts. For a transfer in a browser, watching the browser process may keep the request active long after the download finishes. A timed session is usually easier in that case. A worker or helper process can also outlive its launcher, so choose the process that actually represents the task.
To limit the wait to at most one hour, combine the PID with a timer:
caffeinate -i -t 3600 -w 12345The request ends when the watched process exits or the timer expires, whichever happens first. This form does not launch another command after the PID. It also does not stop the watched task when the timer ends. See Apple’s implementation and the short checks below.
Try a harmless 20-second process example
Paste these three lines together into one Terminal tab:
sleep 20 &
task_pid=$!
caffeinate -i -w "$task_pid"sleep 20 creates a test process that simply waits; it does not put your Mac to sleep. The & runs it in the background, and $! captures its PID immediately. After about 20 seconds, that process exits and caffeinate should return you to the prompt.
During the wait, run pmset -g assertions in a second tab. Look for this caffeinate process’s PreventUserIdleSystemSleep entry, then check again after it ends. Other apps can keep the overall assertion count above zero.
To end only the awake request early, press Control-C in the tab running caffeinate. The independently started test process continues until its 20 seconds are up. The same distinction matters when watching a real job: stopping the watcher is not a way to cancel that job.
When a menu-bar app is more convenient
Terminal works well for occasional, deliberate sessions. A menu-bar app is easier to revisit when you want recurring schedules, cursor movement, or controls tied to a particular app.
Mouse Jiggler offers an idle delay, movement interval, weekday schedules, and deactivation controls. See the scheduling walkthrough for an example. Neither approach should be treated as a promise that closing a MacBook lid will leave a task running.
For the exact options installed on your own Mac, open Terminal and run man caffeinate. Press Q to leave the manual.
How to stop caffeinate
- Return to the Terminal tab where you started the command.
- Press Control-C once.
- Check that the command prompt returns.
A timed command also stops automatically at its timeout. If you have several caffeinate sessions, ending one does not end the others. Stop the specific session you started; there is no need to change system-wide power settings or terminate unrelated processes.
Confirm the request in a second Terminal tab
While the session runs, open another Terminal tab and enter:
pmset -g assertionsLook for the caffeinate process in the process list. A session with -i should have a PreventUserIdleSystemSleep assertion; -di also requests PreventUserIdleDisplaySleep. After stopping your session, its process entry should disappear. Other apps may still have their own requests.
This read-only check helps distinguish a command that is running from a line you typed but never submitted. It does not establish that a remote download completed.
If your Mac still sleeps
Check whether the timeout already ended, the Terminal session closed, or the lid was closed. A timed idle-sleep request is not a guarantee against every sleep cause. If the system stays awake but a transfer stops, continue with the download and upload checks.
For an app that repeatedly reopens sessions, first identify it using Activity Monitor and the power-assertion check.
caffeinate(8) manual. Read it on your Mac with man caffeinate.Make your next session simpler.
Explore Mouse Jiggler’s menu-bar movement, timing, and scheduling controls.
Download for Mac


