Skip to content
DeveloperMemos

Using the Caffeinate Command on Mac

MacOS, Caffeinate, Terminal1 min read

The caffeinate command is a useful tool for preventing your Mac from going to sleep or entering a lower-power mode. It can be useful in a variety of situations, such as when you're running a long task that you don't want to be interrupted, or if you're using your Mac as a server and want to keep it awake all the time.

To use the caffeinate command, open the Terminal app on your Mac (you can find it in the Utilities folder within the Applications folder). Then, type caffeinate followed by the options and arguments you want to use.

Here are some examples of how you can use the caffeinate command:

  • To keep your Mac awake indefinitely, simply type caffeinate. The caffeinate command will run until you cancel it by pressing CTRL + C.
  • To keep your Mac awake for a specific amount of time, use the -t option followed by the number of seconds you want to keep your Mac awake. For example, to keep your Mac awake for an hour, you would type caffeinate -t 3600.
  • To prevent your Mac from going to sleep, but allow the display to turn off, use the -d option. For example, caffeinate -d will prevent the display from turning off, but the Mac will still be able to go to sleep if it is idle for a certain period of time.
  • To prevent your Mac from going to sleep, and to keep the display on, use the -i option. This is useful if you're running a task that requires you to keep an eye on the screen.
  • To prevent your Mac from entering a lower-power mode (such as "Power Nap"), use the -m option. This can be useful if you're using your Mac as a server and want to ensure that it is always available.

It's important to note that the caffeinate command is intended for use in Terminal and is not a standalone app. If you want to keep your Mac awake all the time, it's a good idea to create a script that runs the caffeinate command in the background. This way, you can easily turn the caffeinate command on and off as needed.

In conclusion, the caffeinate command is a powerful tool for preventing your Mac from going to sleep or entering a lower-power mode. It can be useful in a variety of situations, and is easy to use with a variety of options and arguments.