Automatically Quit and relaunch Mac app

I use iFlicks to transcode video on my MacMini, but leaving it open indefinitely has caused problems with my video signal.

I’m looking for a way to quit and then relaunch iFlicks automatically on a schedule to stop the problems.

Does anyone know a way to do it please?

Based on the latest episode of Automators you might be able to use Bunch’s ability to schedule opening and closing bunches to do this.

1 Like

There is, but the problem is that there is no way (that I am aware of) to not quit it in the middle of a transcode.

If you’re OK with that, the only real question is how often do you want to restart it?

1 Like

There are many ways to do this, from writing an AppleScript triggered by launchd (complex) to using Keyboard Maestro (easy).

As @tjluoma points out, the tricky part is making sure you do not quit the app while it is doing something important. If the app has an AppleScript dictionary, you could check to see if it has a way to query its activity status. Then you could make sure it is inactive before quitting it in the KM Macro or other method.

If it does not have the ability to provide that information, another trick is to get its cpu usage with something like ps aux | grep <appname> | grep -r grep for example, parse out the cpu usage, check it for example every 30 days for a few iterations and if the cpu usage is not changing, then assume it is inactive an quit it. A bit more complex shell scripting but not really hard to do.

There is also an app specifically designed for quitting inactive apps. I cannot recall the name offhand but I am sure someone here will remember it.

I would also point out that bunch isn’t really designed for this purpose and would take some creativity in the bunch file to accomplish this task. Also, bunch as far as I know does not automatically trigger (I could be wrong, I have not looked at the documentation recently) and so you still need a way to automatically trigger it.

For this kind of automatic activity, my fallback is always Keyboard Maestro. It’s just the easiest way to get things like this done.

1 Like

I think you mean Quitter by Marco Arment.

That might be a useful tool here.

Agreed, I don’t think Bunch is the tool for this.

Indeed. You could just have a macro that re-starts the app any time it quits.

If iFlicks will prompt you to not quit if it is busy, Keyboard Maestro is also the best way to quit it, because you can send the quit command, and then just wait for the “Are you sure you want to quit” prompt, if it comes, and select ‘Cancel’ if iFlicks is indicating it is busy.

Or, if restarting it once a day is enough, you could just set a time when it’s likely to be idle, such as 4:00 a.m., and have a script quit the app and re-launch it.


Actually, another thought just occurred to me… maybe the best solution is to not leave the app running, launch it when needed, and then immediately quit it when it is finished.

But that’s up to @geoffaire

1 Like