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 have some automated tasks in the form of AppleScripts which I would schedule to run overnight via an iCal event. The event would simply be set to "run script" at "0 minutes before the event" and I'd select the various scripts to run.

Ever since upgrading to Mountain Lion, however, "run script" is now just "open file" and the scripts don't run, they just open in AppleScript Editor.

I tried compiling the scripts into applications to see if I could select those to be opened instead, but they're not available to select from the event (they're greyed out).

  1. How can I get Calendar to run my scripts?
  2. Conversely, is there a better way to schedule scripts to run?
share|improve this question

3 Answers 3

up vote 10 down vote accepted

I wrote an answer to a question about scheduling jobs that could solve a few of the issues for you. That was mostly for a one off time though versus ongoing.

If you have an ongoing job, like one that you would have scheduled through iCal, launchd will work nicely as well.

But if you want an outright replacement to something similar to what you did with iCal/Calendar, it sounds like this great writeup on the Apple Discussions board explains using Automator's 'Calendar Alarm'. One user even said that this new way is even easier to use. I personally think with the extra power of Automator, it also adds new power.

From that site:

Here's a solution that works for me:

  1. In Automator, create a Calendar Alarm
  2. Select Utilities from the library pane
  3. Select & drag Run AppleScript into the workflow area
  4. Copy/paste the AppleScript into the Run AppleScript box
  5. Save the newly created Calendar Alarm
  6. Open Calendar.app, create a new event
  7. Select the Automator calendar as your reference calendar
  8. Select Open File for the alert, and select the file you created in Automator. By default, iCal is the file that comes up when you select Open File.
  9. Change that to the name of the Automator app you created.
  10. Select Other if the file name isn't shown.

enter image description here

The user attached some screenshots to their post, as well, but I have included a screenshot of what needs to be selected in Automator.

share|improve this answer
1  
This looks great! It'll get tested with my tasks tonight, but it looks like it'll work splendidly. One interesting note about the steps outlined, it looks like there's an update to them (possibly new to Mountain Lion, I don't know). When saving the "file" in Automator, there was no option to actually save it as a file somewhere. (Apple's push to move away from the file system, no doubt.) It just saves with a name and that's it. And as soon as it saves, Calendar gets focused with an event automatically created. I just had to adjust the time and set the repeat for the event. –  David Aug 3 '12 at 11:12

It appears that Apple did not carry over the "Run Script" functionality from iCal to Calendar in Mac OS X 10.8, aka Mountain Lion.

You can schedule applications to run on Mac OS X in a number of ways.

Built-In Scheduling Tools

The preferred built-in scheduling method is to use launchd (launch daemon). To use launchd you create launchd job tickets and place them in your ~/Library/LaunchAgents/ folder.

cron is available on Mac OS X but no longer recommended. However, there are many schedules than can be represented by cron and not by launchd.

Apple's launchd documentation is a good place to start.

Third Party Scheduling Tools

If you want a graphical interface or more functionality, there are third party applications available. My company develops Power Manager; others solutions also exist.

share|improve this answer
    
You can represent cron-like schedules with launchd by just adding enough StartCalendarInterval dictionaries. –  ؘؘؘ Aug 3 '12 at 16:42
1  
cron's scheduling language is incredible and extremely powerful. Sadly what provides the same power is difficult to predict accurately without enumerating and testing each minute. This is one reason cron is no longer recommended, it requires polling; launchd can schedule tasks without needing to poll. –  Graham Miln Aug 3 '12 at 19:23

jmlumpkin's answer is spot-on, but you can make it even easier on yourself. As I described in a blog post, you don't need to copy and paste the script into the new workflow you create. You can call the original AppleScript from inside the workflow, instead:

on run {input, parameters}

    run script file "Macintosh HD:Some Directory On Disk:a cool script.applescript"

end run
share|improve this answer

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.