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.

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

1 Answer 1

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 http://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man5/launchd.plist.5.html

share|improve this answer
2  
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
1  
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

 
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.