From XPUB & Lens-Based wiki

Starting up a Daemon/Agent on OSX boot/login

This simple recipe, will give some clues on how to have your favorite app/daemon/software automatically started with your OSX session or boot.

OSX uses Launchd to manage daemons. You can define new jobs that can:

  • run as a user only for a given user
  • run as a user a system wide available daemon/app
  • run as root a system wide daemon/app

This current recipe works for a daemon that will be owned by the user logged in, and made available to all users.

Property List

The job is described as a property list. A very simple one that calls a Python script would be:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Pay attention to the following parameters:

  • <string>xx.mydomain.mydaemon</string>: unique name of your job
  • <string>/path/to/</string>: points to your daemon/software (make it available system wide, ie /Applications or /usr/bin)
  • <key>RunAtLoad</key>: autostart when users login

install your job

  • Copy the above in a file called xx.mydomain.mydaemon.plist and save it under /Library/LaunchAgents
  • Reboot
  • If is a daemon (or simply running in loop) it should be visible in the process list and owned by your user. You can check that with the following command:
ps aux | grep


You can always manually start/stop/control your job using the command-line launchd application, just open a terminal and type launchctl, then help.