- One Tip a Week
- Posts
- One Tip a Week: Stay Caffeinated?
One Tip a Week: Stay Caffeinated?
This week’s tip of the week is for macOS users only, but it’s a nice little built-in hidden gem, caffeinate
. This command can be used in scripts or run at the command line to prevent your computer from going to sleep. I’ve used other tools in the past like Amphetamine, which is a solid app, but I like the fact that there’s something built-in.
This came on my radar after I did a live stream with my buddy Den about MCPs (check it out!). I didn’t have Amphetamine installed on my work machine so a couple times during the live stream, my computer’s screen went to sleep even though the stream was still running. It stopped my camera a couple times which was annoying. Fast forward to caffeinate
. Now when I stream with OBS, my pre-stream script that runs includes caffeinate -d -t 10800
which prevents the computer and display, -d
, from sleeping for 3 hours, -t 10800
.
One thing to note. If you don’t specify a time, your machine will stay awake indefinitely. You can still stop it though. In your shell you can:
CTRL + C to kill it if is still running in your shell
killall caffeinate
Or more surgical,
ps aux | grep caffeinate
and thekill <PID>
, where<PID>
is the process ID from the list of processes you grepped.
There doesn’t appear to be an official page on Apple for this, so check out SS64 for info on caffeinate, or just run man caffeinate
in your shell of choice on macOS.
That’s it! Short and sweet. Until the next one!