← All Tips
Tipp 079 💻Mac⚡Productivity 2 min read

caffeinate: Keep Your Mac Awake via Terminal

TL;DR
Use macOS’s built-in caffeinate command to prevent idle sleep during a long task. Add a one-hour limit so the normal sleep behavior returns automatically.
Checked 3 sources Season: All year

Mac Terminal with the caffeinate command

Keep the Mac awake temporarily

If a download or script needs more time than your usual idle-sleep interval, open Terminal (Command-Space, then type Terminal). Enter caffeinate -t 3600 and press Return. The number is a duration in seconds: 3600 means one hour. Leave that Terminal session running while the task continues. When the timeout expires, the sleep-prevention assertion ends; your Mac can then follow its normal sleep settings again. You do not need to change System Settings.

Choose the right form

  • caffeinate prevents idle system sleep until you stop the command.
  • caffeinate -t 3600 does the same for up to one hour.
  • caffeinate -d -t 3600 additionally keeps the display from sleeping during that period. Use the display option only if you actually need the screen on.

For a specific Terminal task, you can also run caffeinate -i your-command so the assertion lasts for that command's execution. Replace your-command with the real command and its arguments; do not type the placeholder literally.

Stop it and know its limits

Press Control-C in the Terminal session to stop a running caffeinate command early. The command prevents automatic idle sleep, not every kind of sleep: choosing Sleep manually or closing a Mac laptop lid can still put it to sleep. It also does not guarantee that a download, network connection or backup will succeed. Keeping a Mac awake or its display on may increase power consumption, especially on battery. Prefer a timeout that covers only the work you need.

Sources

Selected references used to verify or support this tip.

Was this helpful?

Be the first to rate this tip!


WhatsApp