Sunday, July 29, 2012

Schedule Jobs Using launchd

Nathan Grigg (via Dr. Drang):

Almost anything you can do with cron you can do with launchd, but with more power and flexibility. Unlike cron, launchd does not assume that your computer is always running. So if your computer happens to be sleeping at the time a job is scheduled, it will run the job when it wakes up. This is probably the best feature of launchd, because it allows me to run scripts on my iMac while still letting it sleep when I’m not using it.

I have pieced together what I know about using launchd to schedule jobs from tutorials across the internet, trial and error, and the manuals. This is my attempt to gather all my knowledge about this in one place.

2 Comments RSS · Twitter

[...] Link. Better than cron. by jgordon on July 30, 2012  •  Permalink Posted in share Tagged s [...]

Interestingly, when my job was writing iOS apps I used to use cron for nightly builds, but I had to switch to launchd when Lion came out, as in Lion cron jobs failed to access user secrets such as the Subversion identity to update to the latest code. Overall launchd is less straightforward at first (a plist with a number of fields vs a simple line in crontab), but just as workable and much better to programmatically set up and remove (individual plists and jobs identified by reverse DNS vs a line in crontab).

Leave a Comment