Skip to content

Instantly share code, notes, and snippets.

@dteoh
Created February 23, 2017 23:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dteoh/54ca1cc09fab48dfc331600021ce472f to your computer and use it in GitHub Desktop.
Save dteoh/54ca1cc09fab48dfc331600021ce472f to your computer and use it in GitHub Desktop.
Preventing macOS from sleeping

There is a built-in command line utility caffeinate that can be used to prevent macOS from sleeping.

To prevent macOS from sleeping before a process with given PID exits:

$ caffeinate -w PID

To prevent macOS from sleeping for the next N seconds:

$ caffeinate -t N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment