profile picture

tech, volunteers, public safety, collective intelligence, articles, tools, code and ideas

© Lewis Westbury 2024

Keeping jobs alive with caffeine

tutorial tool

My Mac likes to go to sleep to save power, and that means any long-running processes I have underway will be suspended when it does.

Until recently, I had assumed my best option was to change the power settings. For tasks I want to keep alive, there’s a better option - called caffeinate, available on OS X and Linux.

Just like time (a tool to tell you how long a task took to run), you can prefix a command with caffeinate. Its job is to keep the computer awake until the command exits.


caffeinate ./
caffeinate python ./
caffeinate docker run <image>

It’s really that simple.

Take a look at the manual pages for it on your system to see what other options there are: man caffeine