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
877-865-7002
Today’s Deal Zone Items... Handpicked deals...
$1100 $880
SAVE $220

$999 $779
SAVE $220

$1299 $949
SAVE $350

$799 $549
SAVE $250

$1499 $999
SAVE $500

$799 $549
SAVE $250

$2797 $2497
SAVE $300

$1997 $1797
SAVE $200

$549 $499
SAVE $50

$1699 $949
SAVE $750

$240 $175
SAVE $65

$3399 $2699
SAVE $700

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


Deals Updated Daily at B&H Photo
View all handpicked deals...

Apple 13.3" MacBook Air with Retina Display (Early 2020, Gold)
$999 $779
SAVE $220

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__