I'm running archive utility on an iMac to extract thousands of files so it takes a long time. I will also be running a process in a program called R Studio that may take several days to complete. I need to find a way to keep the system from going to sleep and pausing these processes.
I believe the caffeinate command in terminal is the solution, but I am having trouble getting it to work they way I want it to.
I read the caffeinate man page and tried
caffeinate -w [PID] which appeared to work as long as the display is on. Once the display turns off, the system pauses the process and goes to sleep anyway.
I also thought about trying
caffeinate -s [utility] but per this webpage: http://osxdaily.com/2014/06/16/caffeinate-prevent-sleep-while-command-active-mac-os-x/ I need to specify the full path to the binary for the utility within the .app file and I'm not sure what that path is for either the extract process in Archive Utility or the process I'll be running in R Studio. Using the PID, which I can find in the Activity Monitor once the process has started, seemed more reliable.
I have read this related Q&A on superuser: Keep Mac running with display off However, I'm looking for a more targeted solution than what was suggested:
caffeinate -s. My understanding is that the -s prevents the system from sleeping until caffeinate exits. I'd really like a solution that allows caffeinate to exit automatically when the process is done.
And I'm also really curious why the caffeinate -w assertion stops working when the display turns off.
NEW Q: My process finished its run but caffeinate didn't seem to exit as expected. What am I missing? and how do you terminate caffeinate other than quitting terminal? I've tried
exit caffeinate but that didn't seem to do anything.