docs:mac:launchd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:mac:launchd [2011/04/16 21:59] – [Example: Apache2] billhdocs:mac:launchd [2012/07/01 15:28] (current) billh
Line 4: Line 4:
 Mac OS X provides two methods for launching daemons: [[creating startup items|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 provides two methods for launching daemons: [[creating startup items|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.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.+  * Mac OS X v10.4 and later: 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 =====+===== Creating a launchd job =====
   - review the [[#External Links]] below to get a better understanding of how launchd and launchctl work   - review the [[#External Links]] below to get a better understanding of how launchd and launchctl work
   - open Property List Editor (included in Developer Tools) or use a text editor to create files like the examples below   - open Property List Editor (included in Developer Tools) or use a text editor to create files like the examples below
Line 96: Line 96:
     <key>WorkingDirectory</key>     <key>WorkingDirectory</key>
     <string>/usr/local/mysql</string>     <string>/usr/local/mysql</string>
 +    <key>RunAtLoad</key>
 +    <true/>
 +</dict>
 +</plist>
 +</code>
 +
 +===== Example: Postgres =====
 +**/Library/LaunchDaemons/local.postgres.plist**
 +
 +  * note - the below script causes console to log this:<code>
 +  * 7/1/12 2:24:05.272 PM com.apple.launchd: (Postgres[20215]) Suspicious setup: User "postgres" maps to user: _postgres
 +</code>
 +    * however, if you try changing the users to _postgres, the launch fails (doesn't have permission to read conf file)
 +
 +<code xml>
 +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
 +"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
 +<plist version="1.0">
 +<dict>
 +    <key>Label</key>
 +    <string>Postgres</string>
 +    <key>Disabled</key>
 +    <false/>
 +    <key>UserName</key>
 +    <string>postgres</string>
 +    <key>GroupName</key>
 +    <string>postgres</string>
 +    <key>Program</key>
 +    <string>/usr/local/pgsql/bin/postgres</string>
 +    <key>StandardOutPath</key>
 +    <string>/usr/local/pgsql/log/postgres.log</string>
 +    <key>StandardErrorPath</key>
 +    <string>/usr/local/pgsql/log/postgres.log</string>
 +    <key>EnvironmentVariables</key>
 +    <dict>
 +    <key>PGDATA</key>
 +    <string>/usr/local/pgsql/data/</string>
 +    </dict>
     <key>RunAtLoad</key>     <key>RunAtLoad</key>
     <true/>     <true/>
Line 113: Line 151:
   * [[http://www.codepoetry.net/products/launchdeditor|Launchd Editor]]   * [[http://www.codepoetry.net/products/launchdeditor|Launchd Editor]]
   * [[http://www.peterborgapps.com/lingon/|Lingon]]   * [[http://www.peterborgapps.com/lingon/|Lingon]]
- 
  
  • docs/mac/launchd.1303012777.txt.gz
  • Last modified: 2011/04/16 21:59
  • by billh