Monday, March 25, 2013

launchctl / launchd on OSX

Launch definitions are in the form of plist documents

List jobs managed by launchctl (shows job label)
launchctl list

Show detail information about launchctl managed job
launchctl list job_label
i.e. launchctl list homebrew.mxcl.postgresql
# output will look like:
"Label" = "homebrew.mxcl.postgresql";
"LimitLoadToSessionType" = "Aqua";
"OnDemand" = false;
"LastExitStatus" = 0;
"PID" = 17312;
"TimeOut" = 30;
"StandardErrorPath" = "/usr/local/var/log/postgres/stderror.log";
"ProgramArguments" = (


Stop a job managed by launchctl
launchctl stop job_label

Good tool for making launchctl plists

Plists located in one of the following places
 ~/Library/LaunchAgents -  Per-user agents provided by the user. 
 /Library/LaunchAgents   -  Per-user agents provided by the administrator. 
 /Library/LaunchDaemons  -  System-wide daemons provided by the administrator. /System/Library/LaunchAgents -  Per-user agents provided by OS X.
 /System/Library/LaunchDaemons -  System-wide daemons provided by OS X.

No comments: