Automatically restart crashed user-launched app

Hi, all- sorry for the question. I have the following situation:


  1. I have an iMac at home running Mail.app and SpamSieve as my main spam filter for my laptop and iOS devices
  2. It sometimes crashes and when I'm away from home, the inrush of spam makes me sad.
  3. How can I have mail automatically relaunch after it crashes?


I've tried using Lingon to do this, but I can't seem to figure out the appropriate steps to take. There is no single crash log in el Capitain 10.11.3 for apps anymore, making this tip unworkable.


Anyone have any ideas?


Many thanks,

Chris

iMac, OS X El Capitan (10.11.3), null

Posted on Feb 11, 2016 7:22 AM

Reply
4 replies

Apr 28, 2017 11:37 AM in response to Christopher Allbritton

The simplest trick is to also run an AppleScript that restarts Mail if it quits. To make the script, launch Script Editor.app and paste this code into it:


on run

doit()

end run


on idle

doit()

return 60 -- in seconds

end idle


on doit()

tell application "System Events"

set mailApps to every application process whose bundle identifier is "com.apple.mail"

if (count of mailApps) is 0 then

tell application "Finder"

launch application "Mail"

end tell

end if

end tell

end doit


Save it as an application, with the option "Stay open ..." checked. Then place this app somewhere you like, e.g. into your Applications folder, and start it. To make sure it starts even if your Mac is restarted, add it to your Login Items, e.g. by ctrl-clicking its icon in the Dock and choosing the option "Open at Login".


Another way is to use launchd (I tried that but wasn't happy with the results). The link you posted is rather outdated, for OSX 10.4. 10.5 added a new option to react to crashed apps, explained in this MacOSXHints article.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automatically restart crashed user-launched app

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.