Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to automatically run a shell script or command every time interval. I'm running a server and I want to backup some folders every day. I don't want to use time machine because the backups need to be just the raw data.

How do I write a daemon/application/script that will do this? The commands I need to run are pretty simple, and theres more than one I need, so it'd be great if there was a semi-generalized way to do this.

share|improve this question
up vote 3 down vote accepted

On Macs running 10.5 or earlier, I'll use crontab.

On Macs running 10.6 and newer, I'll use launchd. More details here

share|improve this answer
launchd has been available since v10.4. BTW, another option is to drop the script in /etc/periodic/daily, and it'll be run every morning at 3:15am. – Gordon Davisson Nov 22 '11 at 7:50
Is /etc/periodic is managed by crond or launchd? – Jason Salaz Nov 22 '11 at 8:00
@globalnomad: Thats exactly what I was looking for. Thanks. – Kyle Nov 22 '11 at 15:33
Gordon, agree with you launched has been available since 10.4 (there's a pull-down showing just that on the link I provided). I moved my cron jobs to launchd starting 10.6 and the transition was uneventful (which is a good thing). – Global nomad Nov 22 '11 at 15:36
Jason, starting with 10.6.6 /etc/periodic is managed by launched, in earlier OS X it is managed by cron. – Global nomad Nov 22 '11 at 15:40

Your Answer


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.