How to use the command caffeinate (with examples)
- Linux
- December 25, 2023
Caffeinate is a command-line utility on macOS that can be used to prevent the desktop from sleeping. This can be useful in situations where you want to keep your computer awake, for example, when running a long-running task or when watching a movie without any interaction.
Prevent desktop from sleeping (use Ctrl + C
to exit)
Code:
caffeinate
Motivation: The motivation for using this example is to prevent the desktop from sleeping. This can be useful when you want to keep your computer awake for an extended period of time without any user interaction.
Explanation:
Running the caffeinate
command without any arguments will prevent the desktop from sleeping. This means that the computer will not go into sleep mode or the display will not turn off due to inactivity. To exit or stop the command, you can press Ctrl + C
on the keyboard.
Example output:
[1] 45123
Conclusion:
Using the caffeinate
command without any arguments is a simple way to prevent the desktop from sleeping on macOS. It is a useful tool for keeping your computer awake during long-running tasks or when you need to ensure uninterrupted use of the system.