2

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.

4

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 https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html

  • 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .