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?

1 Answer 1


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:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.