This is an old revision of the document!


launchd

Mac OS X provides two methods for launching daemons: startup items and launchd(8) daemons. Which one you use depends largely on the versions of Mac OS X that the daemon must support.

  • Mac OS X v10.3 and earlier: You must use startup items. The launchd service is not supported prior to v10.4.
  • Mac OS X v10.4 and earlier: You can either use startup items or launchd daemons. Using launchd daemons is preferred unless you also require backwards compatibility with versions of Mac OS X prior to v10.4.
  1. open Property List Editor (included in Developer Tools)
  2. create entries in a new file as shown in examples below
  3. save the file to ~/Library/LaunchAgents/<namespaced filename, such as com.example.MyApp.plist>
  4. add the file to launchd in the Terminal
    launchctl load Library/LaunchAgents/com.example.MyApp.plist

local.Apache2.plist

  • Root dictionary
    • Label (string): Apache2
    • UserName (string): _www
    • Program (string): /usr/local/apache2/bin/apachectl
    • ProgramArguments (array):
      • (string): start
    • OnDemand (boolean): false

FIXME - this isn't working yet

local.MySQL.plist

  • Root dictionary
    • Label (string): MySQL
    • ProgramArguments (array):
      • (string): /usr/local/mysql/bin/mysqld_safe –user=mysql
    • OnDemand (boolean): false
  • docs/mac/launchd.1302934580.txt.gz
  • Last modified: 2011/04/16 00:16
  • by billh