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" = (
"/opt/homebrew/bin/postgres";
"-D";
"/usr/local/var/postgres";
"-r";
"/usr/local/var/log/postgres/server.log";
);

};

Stop a job managed by launchctl
launchctl stop job_label

Good tool for making launchctl plists
http://sourceforge.net/projects/lingon/

Plists located in one of the following places
FILES
 ~/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.


https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html


No comments: