Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

What is the difference between cron and lauchd? I have always used cron, but I have recently heard that launchd is better. Why? In what ways is cron better? In what ways is launchd better?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

launchd does a lot more than cron. In addition to running programs at certain times, it can also run them based on other triggers: incoming network connection, when a file is added to a certain folder, etc. It can also relaunch a program if it crashes.

If you're interested in it specifically as a replacement for cron, the main difference is how it handles being asleep or shut down when a job is scheduled to run. In this case, cron simply doesn't run the job, but launchd will notice that a scheduled run has been missed, and run it at the next opportunity (although if it's missed multiple scheduled runs, it'll only run it once).

Edit: I should also point out some things that cron can do that launchd cannot: automatic emailing of failure reports (you'd have to write a wrapper script to do this with launchd) and user-defined jobs that run even when the user isn't logged in (a user can define launchd items in ~/Library/LaunchAgents, but they only run inside a login session).

share|improve this answer
    
Awesome! Switching to launchd! –  daviesgeek Oct 1 '11 at 14:43
1  
At least according to the Daemons and Services Programming Guide, running missed jobs later only applies to jobs scheduled during sleep (not when shut down) and by StartCalendarInterval. –  Lri Apr 6 '13 at 4:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.