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?

  • 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, 2011 at 14:17

1 Answer 1


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.

  • Thank you. Compatibility with 10.3 is not an issue.
    – jjs
    May 10, 2011 at 19:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .