Whats the best way to automatically start an app if its not running? I want to automatically start an application if its not running.   My use is case that if I quit a particular application I want to automatically restart.  Specifically in my case its the Messages app.

I always want to keep the Messages app running so if I quit Messages I want it to restart. 

What's the best way to handle this?
What you are looking for is launchd. 

It will allow you to run an app continuously (auto-start at boot, relaunch when it quits/crash)

To use it add a plist file in ~/Library/LaunchAgents/

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;  
        &lt;true/&gt;
        &lt;key&gt;KeepAlive&lt;/key&gt;
        &lt;true/&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;SomeApp.restart&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
                &lt;string&gt;/path/to/SomeApp.app/Contents/MacOS/SomeApp&lt;/string&gt;
        &lt;/array&gt;
        &lt;key&gt;StartCalendarInterval&lt;/key&gt;
        &lt;dict&gt;
            &lt;key&gt;Hour&lt;/key&gt;
            &lt;integer&gt;5&lt;/integer&gt;
            &lt;key&gt;Minute&lt;/key&gt;
            &lt;integer&gt;10&lt;/integer&gt;
       &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Then load it once with  launchctl load ~/Library/LaunchAgents/SomeApp.restart.plist


The RunAtLoad option will launch the application the first time launchctl runs this.
The KeepAlive option will re-launch the application if it crashes.
The StartCalendarInterval will run it at a certain time. Presumably this is mutually exclusive with the previous two, but is included to show what can be done with launchd
Launchctl will run this after reboots.