I know when using a plist in the launch daemons folder there is a key called <StartInterval>
. I much prefer using launchctl
when I can because it is a lot quicker then writing out a whole plist, but I have not been able to figure out how to get the process to restart after it has been killed. I have already read the man page and haven't found anything there. Is there a way? Typically I use the following command:
launchctl submit -l somename -p /path/to/script -o output.txt -e errors.txt
But that will not restart the program if it is killed after any time interval.
launchctl submit
should already run the program again if it terminates for some reason:To run a program again if it exits with an error, set the SuccessfulExit criteria for KeepAlive to false:
launchd throttles jobs so it takes about 10 seconds for the program to respawn.