Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Automatically restart a crashed program System 10.4
I have been having some problems with Quicksilver crashing. Not very often, but since I prefer to run it without an icon in the Dock or the menu, it's quite annoying when I try to use it the next time. To solve this problem, I decided to use launchd and its ability to react on the change of a file, namely the crashlog for Quicksilver.

I prefer to use Lingon to manipulate the launchd, but here's an example plist as well. In Lingon, use the Assistant and select "Run an application/script when a file is modified." Add a suitable Label and in the last step, use the Path buttons to select the program you would like to restart and its crashlog. Press Create and you should have a working LaunchAgent.

If you don't want to use Lingon, paste that plist into a text editor. Change the WatchPaths and ProgramArguments to fit your system, save the file in ~/Library/LaunchAgents, and name it something like nu.wallner.QuicksilverWatch.plist. Load it with this command in Terminal:
launchctl load ~/Library/LaunchAgents/nu.wallner.QuicksilverWatch.plist
Hope this helps you as it has helped me!
    •    
  • Currently 2.57 / 5
  You rated: 4 / 5 (7 votes cast)
 
[29,260 views]  

10.4: Automatically restart a crashed program | 15 comments | Create New Account
Click here to return to the '10.4: Automatically restart a crashed program' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Automatically restart a crashed program
Authored by: dfbills on Oct 06, '06 08:21:18AM

Very interesting.

---
-d



[ Reply to This | # ]
THANK YOU!!11!
Authored by: mistersquid on Oct 06, '06 10:24:26AM

This is one of the most exciting hints I've ever seen: direct, effective, and abstractable.

By "abstractable" I mean that it can be applied to other problems. In my case, I had been looking for a way to launch a script that would send me an SMS message when a particular file had been accessed from my webserver. (By sending an email that has an embedded .gif which is hosted on my webserver, this script can notify me when a particular email has been accessed, presuming the recipient loads the image/signature in question).

I tried using bubblegum which is a great program except the daemon magically loses the ability to execute its associated script after a dozen minutes or so.

So, a heartfelt thanks to you, fredrikw. This is the most useful Macosxhint I've come across in months!



[ Reply to This | # ]
THANK YOU!!11!
Authored by: cvk_b on Oct 07, '06 02:04:42PM

I concur.



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: dbeecher on Oct 06, '06 09:06:13PM

Nice hint. I thought I would mention my less-daunting method of reopening quicksilver when it crashes. I have an alias of the quicksilver app hidden as far as possible down in the lower-left-hand corner of my desktop. I have renamed it, " " -- i.e. just a space. So when quicksilver crashes, I apple-tab to finder, hit space, and hit apple-o. And it opens!



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: fredrikw on Oct 07, '06 08:50:43PM

My main problem was that I never knew when it had crashed, since I neither have an icon in the dock nor in the menu-bar.

/Fredrik



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: metiure on Oct 08, '06 03:07:18AM

ditto



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: bluehz on Oct 08, '06 05:18:13AM

I have used this technique for over a year to keep Quicksilver running. WOrks fantastic! There has always been one issue I was trying to solve - when a shutdown or restart command is issued, all applications are quit including Quicksilver, but before the system has had time to restarts/shutdown, the daemons (incl Quicksilver) relaunch - thinking thats the right thing to do. No big deal - the system just quits the application again and shutdown/restart continues as usual. I just always thougt there must be some way to tell the launch daemon to "wait" x period of time before relaunching - hence giving time for the shutdwon/restart to complete without the daemon having time to realunch. There are some fields in the launchd config files for pause/wait - but I have tried setting them and they never seem to have any effect. I personally feel like there should be some mechanism built-in that recognizes a restart/shutdown command and doesn't even attempt to relaunch - but only Apple can fix that. Does anyone know a method to keep the daemons from relaunching during a restart/shutdown.

Also - in particular with Quicksilver - there is one annoyance when Quicksilver updates itself or plugins and requires a relaunch - the applications shuts down and relaunches itself. Unfortunately the system sees that also and launches the daemon to restart Quicksilver and then youhave two instances of Quicksilver running. Once agin - a minor annoyance, but something that I feel should be able to work properly.



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: fredrikw on Oct 08, '06 02:48:02PM

I think you used a different feuture of launchd, to keep an application running. I decided to go for my approach because sometimes I want to quit an application withou restart. Monitoring the crashlog only restarts the application on a crash, hence solving all of your issues.

/Fredrik



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: el tumbador on Oct 09, '06 02:23:43AM
Really great hint. Saves me a lot of clicking due to quicksilver crashing on every attempt to mount afp-volume. cheers PS: there is a typo in for the copy/paste people like me here:
launchctl load ~/Librarry/LaunchAgents/nu.wallner.QuicksilverWatch.plist
launchctl load ~/Library/LaunchAgents/nu.wallner.QuicksilverWatch.plist 
Libra_r_y

[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: settledown on Dec 06, '06 09:11:30AM

In the plist, do you have to point to this:
<string>/Applications/Quicksilver.app/Contents/MacOS/Quicksilver</string>

or can you simply point to the .app
<string>/Applications/Quicksilver.app</string>

I'll guess and say no, because Quicksilver.app is actually a package (as are most apps), and /Quicksilver.app/Contents/MacOS/Quicksilver is the actual executable.

Am I correct?



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: asmeurer on Sep 26, '07 08:11:31PM

If you use Lingon, it tells you that you need to use the executable.



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: asmeurer on Sep 26, '07 08:16:38PM

This is amazing. restarting quicksilver has always been a nusaunce to me (it's a great program, but it sure likes to quit a lot). I never knew of Lingon or launchd, but I am sure I will be using it quite a bit from now on.



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: ZZamboni on Jan 29, '08 05:13:40AM
This is a very nice hint. As an alternative to WatchPaths, you can simply use KeepAlive, like this:

<?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">
<dict>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>org.quicksilver</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Applications/Quicksilver.app/Contents/MacOS/Quicksilver</string>
        </array>
</dict>
</plist>
And I second the recommendation for Lingon. Very nice utility.

[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: jasonh1234 on Dec 17, '08 07:22:43PM

I would like to start doing this and have downloaded Lingon but I don't know what to do from here. Can someone type out a step by step tutorial for a total newb?



[ Reply to This | # ]
10.4: Automatically restart a crashed program
Authored by: TBoxman on Jan 21, '09 08:54:16AM

I need to keep EvoCam running on my OS X Server Mac Mini and hope this is the best way to do it. Step by Step instructions would be great!

TIA,
Terry

---
----------
Terry Box
Designimations
www.designimations.com



[ Reply to This | # ]