Automatically relaunch unresponsive Mac app
The Insync client on my macOS 10.12.5 installation freezes at least daily, which I only notice when I find files are not syncing across my computers. My hacky solution was to write an AppleScript to check if the client is unresponsive and create a launchd
agent to start the client any time it is not running or crashes (different than “Not Responding”).
I use Lingon X to manage my automatic launching, so I created these as follows:
Launcher
- User: me
- Name:
Insync Launcher
- Run:
/Applications/Insync.app/Contents/MacOS/Insync
- When: Launch again if it crashes
Killer
- User: me
- Name:
Insync Killer
- Run:
/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal ~/kill_unresponsive_insync
- When: Scheduled: Every hour on minute 3
The script must have execute permissions (chmod u+x ~/kill_unresponsive_insync
) and Terminal.app must be added under System Preferences > Security & Privacy > Privacy > Accessibility. As this is written, Activity Monitor will be closed if you had it open when the script runs. It should be easy to modify to address this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Credits: problem, original script idea, security workaround