Can launchd on OSX (specifically Mountain Lion) be configured to work like watchdog, monitoring processes, after having launched them, to keep them alive? If so, how?
Can launchd on OSX (specifically Mountain Lion) be configured to work like watchdog, monitoring processes, after having launched them, to keep them alive? If so, how?
Create a .plist file telling launchd what to launch, when to launch it, and what to do when it exits. Here's a very simple example:
There are lots more options; see Apple's developer docs and the launchd.plist man page. Once the file is created, place it in /Library/LaunchDaemons/local.someidentifier.plist (note that the filename should match the "Label" entry). Set its owner to root, group to wheel, and permissions to 644. It'll be loaded when you restart the computer, or you can load it manually with
sudo launchctl load /Library/LaunchDaemons/local.someidentifier.plist