Cron and launchctl on Mac OS X 10.5 Leopard

I was searching for a way to set up a cron job on my Mac, and couldn't find anything that spelled it out exactly how I needed it. got me really really close though. I did finally get it working, so I thought I'd explain the crucial parts of my setup.

My goal is to port this cron command to my Mac:
*/5 * * * *   wget -O - -q -t 1 http://drupaldev1/cron.php

1. Create a .plist file. A new empty plain text file. I named mine local.drupaldev1.plist, since this is for a local development site on my computer. I placed it in ~/Library/LaunchAgents/ but you can put it anywhere on your computer.

2. Open that file in a plain text editor and paste in this starter code

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

The first string listed under ProgramArguments is the program to execute. All strings that immediately follow it are its arguments.

3. Activate the file by doing this at the command line:

launchctl load /Users/my_username/Library/LaunchAgents/local.drupaldev1.plist

If you need to make changes to it, unload it and reload it.

launchctl unload /Users/my_username/Library/LaunchAgents/local.drupaldev1.plist
launchctl load /Users/my_username/Library/LaunchAgents/local.drupaldev1.plist

4. To make it load automatically when you startup your mac, create this file: ~/.launchd.conf and paste in the line above, minus launchctl:

load /Users/my_username/Library/LaunchAgents/local.drupaldev1.plist

5. The sites that I found useful...