When one needs to run long-running computations on macOS, caffeinate utility is very handy.
However, it is not very clear from the documentation, which flags I suppose to use?
man caffeinate says:
-i Create an assertion to prevent the system from idle sleeping.
-s Create an assertion to prevent the system from sleeping. This
assertion is valid only when system is running on AC power.
I struggle to see the difference. Could someone shed the light on this, please?
CodePudding user response:
The -i flag uses the PreventUserIdleSystemSleep assertion status which prevents the entire system from idle sleeping, which is the default mode when no assertion flags are specified.
The -s flag uses the PreventSystemSleep assertion status, which is only valid when your device is connected to an AC power.
The core difference is that with -i flag, it prevents the kind of sleep that is activated when the user sits idle for a certain period of time, but does not prevent the system from sleeping when you (or something else) command it to. The -s flag, on the other hand, prevents the entire system from sleeping regardless, even when it's instructed to do so.
P.S. You can see the assertion type created by caffeinate using pmset -g assertions | grep 'caffeinate'.
