I am running a JXA script as an agent using launchctl
. The main logic of the script is supposed to be run at intervals of 2 seconds, which I have achieved using an infinite loop and delay
. However, whenever my macbook goes to sleep the script stops execution and I have to unload and load the agent manually again.
My script:
for(;;) {
// (Open browser and check whether a tab exisits or not)
<APPLICATION LOGIC >
delay(2);
}
Can I do something to ensure that this script keeps on running even after my macbook wakes up?