Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Donka

macrumors 68030
Original poster
May 3, 2011
2,864
1,459
Scotland
Hi,

I have an issue with my Mac sleeping after the set period when there is a background process running - currently set to 15 mins. While this process is running, which could be anything from 20 mins to a couple of hours, I wish to keep the Mac awake.
There is a log file which is regularly updated while the process is running so I'm thinking if there is a way of checking the timestamp of this log file on a regular basis. If it has changed for example in the last 10 mins, perform some action that will keep the Mac awake e.g. invoke caffeine or mimic a cursor movement or similar?

Does anyone have any thoughts or ideas on how to achieve this? I'm new to this kind of thing but reasonably tech savvy and happy to learn.
 
It's note quite what you want, but it's probably easier then messing with a script: Caffeine will keep your mac awake indefinitely or for a set period of time.

Thanks - I already use caffeine but I want something to work in the background automatically as I will not be at the mac at the time - it will be running as an on demand server. I have found a couple of possible app solutions that I will try out tonight - Jiggler and Wimoweh.
 
Does anyone have any thoughts or ideas on how to achieve this? I'm new to this kind of thing but reasonably tech savvy and happy to learn.

Have you seen caffeinate(8)? If you can run your background process with it it should be trivial. Otherwise you could do some horrible hack like:

Code:
caffeinate -i sh -c 'while [ $(( `date +%s` - `stat -f '%m' logfile.log` )) -lt 300 ]; do sleep 10; done'
 
Have you seen caffeinate(8)? If you can run your background process with it it should be trivial. Otherwise you could do some horrible hack like:

Code:
caffeinate -i sh -c 'while [ $(( `date +%s` - `stat -f '%m' logfile.log` )) -lt 300 ]; do sleep 10; done'

Thanks - I read briefly about that today and I suspect any script would feature that but I will hold off until I can test these two apps I found tonight. If the process spawns a new process, I should be able to use the apps to keep awake until that process finishes. If it doesn't spawn a new process but the parent process uses additional CPU then I should be able to keep awake while that process's CPU is above a specific threshold.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.