Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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
Question marked as Best reply

Posted on Apr 28, 2017 11:37 AM

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.

4 replies
Question marked as Best reply

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.

Aug 10, 2017 6:26 AM in response to pastramowitz

You'll have to replace "com.apple.mail" with the bundle identifier of the program you want to have restarted, and replace "Mail" with the name of the program.

I can't tell you the bundle identifier for Plex Media Server, though. It's something you'll have to google or ask for help on how to figure that out the bundle identifier of any Mac app.

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 ID.