Automatically relaunch a closed application I have an application that opens when I login.

Is there a way to relaunch it automatically if it crashes or if I close it inadvertently?
(the application in question is Transmission if there is any solution specific to this app)

In a perfect world, it could even be launched even without me opening a session.

thanks.
Here is my launchd script to keep SomeApp always running. It is in ~/Library/LaunchAgents/ and called SomeApp.restart.plist

&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;/dict&gt;
&lt;/plist&gt;


Load it once with

launchctl load ~/Library/LaunchAgents/SomeApp.restart.plist


Launchctl will run this after reboots.


RunAtLoad will launch the application the first time launchctl runs this
KeepAlive will restart it if the application quits (CMD+Q or crash)


Should run forever. If you want a GUI tool to help, Lingon works even though development has stopped.