Mac OS X: launch daemons vs launch agents

There are two types of services that launchd manages:

launch daemons can run without a user logged in. Launch daemons cannot display information using the GUI. Launch daemon configuration plist files are stored in the /System/Library/LaunchDaemons folder (for those provided by Apple et al) and /Library/LaunchDaemons (for the rest).  Launch agents run on behalf of a user and therefore need the user to be logged in to run.  Launch agents can display information through the window server. As with launch daemons, launch agent configuration plist files are stored in the /System/Library/LaunchAgents and /Library/LaunchAgents. User launch agents are installed in the ~/Library/LaunchAgents folder.

  • Abhinav

    I m confused among agent and daemon on osx

    is it possible to use an executable eithwer as an agent or a daemon?
    My doubt is that agent and daemons are treated and launched same way by launchd ( here i am not considering things like WindowServer, UsersDirectory, root access etc etc).
    Does it mean that same minimal code, BSD based with launchd flavour can be used as an agent or daemon as desired (just for sake of exercise)?

    • http://www.krypted.com Charles

      Correct, agents are more for users and daemons for systems, but you should be able to call the same binary from either

  • http://ajduncan.org/ Andy Duncan

    Thanks for this article. I’m a recent mac user (long time FreeBSD, Linux user) and was confused about how Launch daemons and agents worked.

  • http://splice.tv Adam Betker

    Very simple and right to the point, thanks krypted.