Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 create a "startup item" in os x. All of the recent documentation suggest that launchd should be preferred over traditional Startup Items.

However, launchd seems to be geared towards launching actual daemons, not for quick tasks that do their work and exit. The developer library document says:

Important: If your daemon shuts down too quickly after being launched, launchd may think it has crashed. Daemons that continue this behavior may be suspended and not launched again when future requests arrive. To avoid this behavior, do not shut down for at least 10 seconds after launch.

This gives me the impression that launchd is not the way to go. Implementing a 10 second sleep sounds like a sloppy solution.

In essence, my question boils down to this: What is the correct way to run a "Hello world" program at startup? Is launchd the wrong tool here?

share|improve this question
1) If you are programming something I'd vote to move this to StackOverflow 2) It all depends on your real world use case. Discussing about a Hello World program is not useful. 3) launchd should be used for background processes. In any other case, use "normal" startup items, as explained here. – slhck May 10 '11 at 14:17
up vote 0 down vote accepted

Unless you need compatibility with old versions of OS X (i.e. 10.3 or earlier), I'd use a LaunchDaemon. The issue about daemons exiting too quickly is only a problem if launchd is supposed to relaunch the daemon. If I understand your case, this isn't relevant. The reason I'd use a LaunchDaemon rather than a StartupItem is that the boot process will wait for StartupItems to complete; I haven't tested this well, but my impression is that even a single fairly fast StartupItem will significantly slow the boot process.

So, I'd go with a LaunchDaemon. Just make sure its .plist includes:


If your program spawns any subprocesses that need to keep running after the parent exits, you should also include:


... to keep launchd from "cleaning up" leftover subprocesses.

share|improve this answer
Thank you. Compatibility with 10.3 is not an issue. – jjs May 10 '11 at 19:56

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.