This is an old revision of the document!
launchd
Background
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.
Basic Instructions
- open Property List Editor (included in Developer Tools)
- create entries in a new file as shown in examples below
- save the file to ~/Library/LaunchAgents/<namespaced filename, such as com.example.MyApp.plist>
- add the file to launchd in the Terminal
launchctl load Library/LaunchAgents/com.example.MyApp.plist
Example: Apache2
local.Apache2.plist
- Root dictionary
- Label (string): Apache2
- ProgramArguments (array):
- (string): /usr/local/apache2/apachectl start
- OnDemand (boolean): false