Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to automatically start an application if its not running. My use is case that if I quit a particular application I want to automatically restart. Specifically in my case its the Messages app.

I always want to keep the Messages app running so if I quit Messages I want it to restart.

What's the best way to handle this?

share|improve this question
up vote 5 down vote accepted

What you are looking for is launchd.

It will allow you to run an app continuously (auto-start at boot, relaunch when it quits/crash)

To use it add a plist file in ~/Library/LaunchAgents/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Then load it once with launchctl load ~/Library/LaunchAgents/SomeApp.restart.plist

  • The RunAtLoad option will launch the application the first time launchctl runs this.
  • The KeepAlive option will re-launch the application if it crashes.
  • The StartCalendarInterval will run it at a certain time. Presumably this is mutually exclusive with the previous two, but is included to show what can be done with launchd Launchctl will run this after reboots.
share|improve this answer

As mentioned, launchctl is the command you want. I find that the syntax for launchctl to be rather difficult compared to crontab. Of course, launchctl does much more than cron. Thus, I use Lingon to provide a GUI to manage launchctl.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.