I’ve written a launch agent:
Label
local.mylaunchagent.plist
ProgramArguments
~/my_script.sh
StartInterval
12
StandardOutPath
~/my_log_file
StandardErrorPath
~/my_err_file
RunAtLoad
It works, but it runs every 22 seconds instead of every 12 seconds, because ~/my_script.sh
takes 10 seconds to finish.
launchd seems to be adding the interval time and the execution time together, even though I want the program to be run every interval. I don’t want launchd to wait for it to finish.
So I tried running the program in the background:
ProgramArguments
/bin/zsh
-c
~/my_script.sh & disown
But now I don’t get any output at all, so I suspect that launchd kills all spawned processes as soon as the process that it launched exits.
So my question is, how can I start a slow command (takes an unpredictable 10+ seconds to finish) every 12 seconds reliably?