Archived Mac & OS X Uncategorized

Scheduling AppleScript using iCal

A few days ago I published an article that made my AppleScript backup ‘system’ available for download.  One of the things missing from that article was how to schedule the script so it runs backups automatically – I’m going to address that today.

There are a ton of ways to accomplish the scheduling a script to run.  If you’re hardcore you can use Cron (I won’t cover that here), you can purchase some scheduling software for OS X or you can do what I do – use iCal.

But iCal is a calendar … isn’t it?

Yes, it is.  However, because it’s a calendar, you can add events and set reminders for them.  See where I’m going with this?  Correct – you can run an AppleScript as part of an iCal event’s alarm.  If you read the article about my AppleScript backups, you’ll remember that I said that the idea was to do things with built-in apps, if possible.  Every OS X installation includes iCal by default so it just makes sense to use it here.

Won’t my calendar get messy?

iCal allows you to setup separate calendars for different types of events so no, it won’t get messy if you don’t want it to.  For example, I have a calendar called ‘Backups’ and it holds … wait for it … backups.  🙂  My backup script runs each day at 8:00 p.m. without me having to do anything manually.

Here’s an example of what one of my backup events looks like.  Note that the event is set to happen 15 minutes after the actual backup starts, with the reminder event triggering 15 minutes before that, i.e. at the actual time the backup is to start.

iCal event to run the backup script
iCal event to run the backup script

It really is that simple.  You don’t need anything other than what comes with your OS X installation to do any of this either – that makes it completely free.

If you end up using any of this, I’d love to hear about it.  Thanks for reading!