Help!

What is this, anyway?

Launchd was designed at Apple as a replacement for init.d, crond, rc.d, etc. Launchd not only provides everything that cron does, it can do so with even more flexibility and power. The only downside is that the XML configuration files required by launchd are nowhere near as simple to write.

That's where this application comes in. It's designed to be a simple way to generate common cron-style launchd plist files for use on your own system.

Installing a plist

To install a plist to run as your user:

# Create a folder for for the plists, if it doesn't already exist
mkdir -p ~/Library/LaunchAgents

# Put your plist in this directory
cp ~/Downloads/com.zerowidth.launched.your_script.plist ~/Library/LaunchAgents

# And load it up with launchctl:
launchctl load -w ~/Library/LaunchAgents/com.zerowidth.launched.your_script.plist

If your plist needs to run as a different user, including root, you'll need to install it to the systemwide launch daemons folder instead:

# Put your plist in the system directory
sudo cp ~/Downloads/com.zerowidth.launched.your_script.plist /Library/LaunchDaemons

# And load it up with launchctl:
sudo launchctl load -w /Library/LaunchDaemons/com.zerowidth.launched.your_script.plist

When you generate a launchd plist with this application, there are also instructions and scripts for installation on the generated plist's page.

Uninstalling a plist

Uninstalling a plist is just as easy as installing it. For a user plist:

launchctl load -w ~/Library/LaunchAgents/com.zerowidth.launched.your_script.plist

And for root,

sudo launchctl load -w /Library/LaunchDaemons/com.zerowidth.launched.your_script.plist

Debugging

If your plist doesn't seem to be running correctly, you can debug it by looking at the logs in console.app. Fortunately, launchd prefixes any activity with the label defined in your plist. So, continuing with the above example, search for com.zerowidth.launched.your_script to find any log entries related to your job.

Isn't there a tool to make this easier?

Yes. gem install lunchy && lunchy --help

Privacy and Security

This application has no way of listing the plists that have been created so far, and each plist is identified by a UUID rather than an incrementing id, to make enumeration difficult. Still, you should ensure that you keep private data out of the plists if possible.

To prevent accidental or malicious changes, it's not possible to edit a plist. Instead, each new version of a plist has a different identifier.

Learn More

man launchd
man launchd.plist

Who's responsible for this nonsense?

Feel free to blame Nathan Witmer. Want to contribute? Find this on github.