Keeping Mac OSX up and sleepless while task / app is running

I want to leave rsync working over wifi for hours turned on AC power. But when I do so the Mac breaks the connection after some time.

On Energy Settings pane it's configured to "Computer Never Sleep", "Put hard disk to sleep when possible" and "Wake for network access".

Plus it'd be good if the mac actually goes to sleep once the task is done.

I realize a very similar question have been asked before and that there is pmset and insomniaX, but I don't want the machine to be sleepless. And I don't want to keep installing more and more extensions, nor have to tweak through pmset every time.

I want it to natively behave as expected - stay awake while I leave it running a task, and then go to sleep "when possible". This time is due to rsync, but next time could be something else.

Am I expecting too much as usual? Can I fix it? Is it even broken?


Solution 1:

Caffeinate

For example:

caffeinate -i rsync -avz someuser@somehost:somefolder /some/local/folder

From the man page:

EXAMPLE
     caffeinate -i make
        caffeinate forks a process, execs "make" in it, and holds an
        assertion that prevents idle sleep as long as that process
        is running.

It can also be used for situations like "don't let the display sleep while I'm watching this movie":

caffeinate -d # in effect until you hit Ctrl+C

... or "stay awake for the next 10,000 seconds":

caffeinate -t 10000

See man caffeinate for details.

Solution 2:

Jiggler can be set to only "jiggle" the mouse when it's running. This will prevent the screen and the computer from sleeping. This will not work on a laptop with the lid shut. For that you'd need InsomniaX or another kext based application.

enter image description here