Free tools

caffeinate command builder

Keep your Mac awake from Terminal without memorizing flags. Tick what you need, set how long, and copy the command. Every flag is checked against Apple's man page.

What should stay awake?

Keeps the screen on.

The Mac will not go to sleep for being idle. This is also what caffeinate does when you give it no flags.

Stops the disk from spinning down while idle.

Only takes effect while the Mac is plugged in.

Turns the display on if it is off. Without -t it only lasts 5 seconds.

How long?

= 1 hour

Your command

caffeinate -di -t 3600

This command keeps the display awake and stops the Mac from idle sleeping.

The assertions are dropped after 1 hour (3600 seconds).

Everything runs in your browser. Nothing is stored or sent anywhere. Flag meanings follow Apple's caffeinate(8) man page (man page, SS64).

Every caffeinate flag, in plain English

caffeinate ships with macOS. It creates power assertions, which are requests to the system to hold off on a particular kind of sleep. If you run it with no flags, it prevents idle sleep until you stop it.

  • -d prevents the display from sleeping.
  • -i prevents the system from idle sleeping.
  • -m prevents the disk from idle sleeping.
  • -s prevents the system from sleeping. Apple notes this is only valid when the Mac is on AC power.
  • -u declares that the user is active. If the display is off it turns it on and keeps it from idle sleeping. Without -t, it uses a default timeout of 5 seconds.
  • -t seconds drops the assertion after that many seconds. It is not used when you run a command through caffeinate.
  • -w PID waits for that process to exit, then releases the assertion. It is ignored when you run a command through caffeinate.

You can also put a command after caffeinate, for example caffeinate -i ./backup.sh. The assertions then last exactly as long as that command runs. Source: caffeinate(8) man page.

Handy examples

  • caffeinate -d: keep the screen on until you press Control-C.
  • caffeinate -di -t 3600: keep the screen on and stop idle sleep for one hour.
  • caffeinate -s: stop the Mac sleeping while it is plugged in, for example during a long download.
  • caffeinate -i -w 4821: stay awake until process 4821 finishes.

What caffeinate does not do: Teams and Slack status

Keeping a Mac awake and keeping your chat status green are two different things. Teams and Slack decide when you are Away from how long your computer has gone without keyboard or mouse input. caffeinate's -d, -i, -m and -s flags only hold off sleep, so your screen can stay bright while Teams still turns yellow after a few quiet minutes.

The -u flag is the closest thing. Apple documents it as declaring that the user is active and turning the display on, and without -t it only lasts 5 seconds. Apple does not describe it as something chat apps read, so do not count on it to keep your status Available.

More detail in Why Amphetamine and Caffeine will not keep Teams or Slack active, and you can watch the exact Away thresholds with the free Teams Away timer.

FAQ

What does caffeinate do on a Mac?

caffeinate is a built-in macOS command that creates power assertions to change sleep behavior. With no flags it prevents idle sleep until you stop it. Flags let you also keep the display, the disk or the whole system awake, and -t or -w control how long it lasts.

How do I keep my Mac awake from Terminal for one hour?

Run caffeinate -di -t 3600. That keeps the display on and stops idle sleep for 3600 seconds, then caffeinate exits on its own.

What is the difference between caffeinate -i and -s?

-i prevents the system from idle sleeping. -s prevents the system from sleeping at all, but Apple notes it is only valid while the Mac is on AC power.

Does caffeinate keep Teams or Slack showing Available?

Not reliably. caffeinate stops your Mac from sleeping, but Teams and Slack mark you Away based on how long there has been no keyboard or mouse input. The -u flag declares user activity, but Apple documents it as turning the display on, and without -t it only lasts 5 seconds.