Projects
Browse Source     Search     Timeline     Wiki

Launchd

Mailing Lists

Documentation

  • launchd is a process that manages all other processes in OSX, in particular the processes that start at boot, scheduled jobs, and processes that respond automatically to particular events. Read the man page: launchd
  • launchd reads plist files to fined out what to do with each process. It's pretty easy to make your own, these replace rc.d, crond, inetd etc on other systems. Read the man page launch.plist for information about the formats.
  • You can load and unload jobs manually with launchctl. It's useful for other things, too. Read the man page to see what you can do with launchctl launchctl

Additional Notes

LimitLoadToHosts or LimitLoadFromHosts

If you use LimitLoadToHosts or LimitLoadFromHosts at startup, you'll need to specify your host name in /etc/sysctl.conf. Otherwise, DHCP may not give you a host name early enough. For example, you could add this line:

kern.hostname=snow.example.com

Program and ProgramArguments

The man pages say to read about execvp carefully. Here's why: "Program" takes a single argument - the file name of the executable. ProgramArguments takes an array of arguments. The first of these is the file name of the executable. So, if you use both Program and ProgramArguments, then you need to give the file name of the executable twice. For this reason, it's easier if you use "Program" if and only if you aren't passing any arguments.

Here's how to launch a program without any arguments

<key>Program</key>
    <string>/bin/myprog</string>

Here's how to launch a program with one argument, equivalent to /bin/myprog --config /Users/foo/prog.conf on the command line:

<key>ProgramArguments</key>
<array>
    <string>/bin/myprog</string>
    <string>--config</string>
    <string>/etc/prog.conf</string>
</array>