All Posts by Date or last 15, 30, 90 or 180 days.
also by Lloyd: diglloyd.com photography and WindInMyFace.com

Thank you for buying via links and ads on this site,
which earn me advertising fees or commissions.
As an Amazon Associate I earn from qualifying purchases.

Other World Computing...
B&H Photo...
Amazon
As an Amazon Associate I earn from qualifying purchases.
Memory Upgrades for 2019 Mac Pro - Save Up to 65% vs Factory Costs
Upgrade the memory of your 2018 Mac mini up to 64GB

How To Prevent System Sleep while a Terminal Command is Running: caffeinate

As part of my work, I frequently work remotely, relying on a cellular data via a personal hot spot on my iPhone.

Even with a cell phone booster, internet speed can be quite limited (think 10K/sec at times!), and sometimes flaky too—remote areas don’t exactly have great cell phone coverage, if at allm and an hours-long driving round trip is a huge time-waster.

Here’s a nasty little behavior of macOS: it doesn’t much care what you are doing in something like Terminal—computation, network access, disk access, etc are all ignored. So you take a short break, only to find that macOS has put the machine to sleep and effectively aborted the job.

Example

I use a source code management system for my web servers called git, and I frequently do a git push to sync my local development system to the server:

git push

But if macOS sleeps the system, the process goes to sleep, and when it wakes up the network connection is aborted. All that cellular data gone to waste, and job not done.

The solution is to prevent system sleep until the push is done using 'caffeinate':

caffeinate git push

Since I do this a lot, I like to make a shortcut (alias) for it:

alias push="caffeinate git push"

Example 2

Suppose you want to verify a large volume 'Photos' using IntegrityChecker. You want the system to sleep only after the verify has finished.

caffeinate icj verify Photos

View all handpicked deals...

SanDisk 256GB Extreme PRO UHS-I SDXC Memory Card
$100 $55
SAVE $45

diglloyd.com | Terms of Use | PRIVACY POLICY
Contact | About Lloyd Chambers | Consulting | Photo Tours
Mailing Lists | RSS Feeds | Twitter
Copyright © 2020 diglloyd Inc, all rights reserved.
Display info: __RETINA_INFO_STATUS__