Since upgrading to Lion, I have seen a sleight decrease of productivity when it comes to using iCal. As a result, I am trying alternatives such as BusyCal. The application seems great, however I cant set an alarm to run a script as I could in iCal.

Hence, I want to become independent from iCal and have an AppleScript run everyday without having to keep iCal running. Any idea of how to do this?

link|improve this question

60% accept rate
feedback

1 Answer

up vote 5 down vote accepted

You can run a cronjob using crontab.
So basically, to run a cronjob, you will need to type nano ~/crontab in Terminal. This will create a new file called "crontab" in your home folder, and open up a simple text editor in Terminal. Type:

* * * * * osascript ~/Desktop/theScriptToBeExecuted.applescript

This will run an AppleScript named "theScriptToBeExecuted.applescript" located on your desktop, every minute. The five "*" before the osascript command specify the time. Here's a table to show you what each field stands for:

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

So to run the same command at one minute past midnight (00:01) of every day of the month, of every day of the week, type this in the file:

1 0 * * * osascript ~/Desktop/theScriptToBeExecuted.applescript

If you need more info, check out this article on cron.

To save the file that you're working on, type Control+X (exits), then Y (tells Terminal that you do want to save the file), then Enter Now type at the prompt cron ~/crontab This tells cron that it should be looking at the crontab file, if your file is named "crontab" in your home folder.

Another alternative is Cronnix It's a GUI for crontab.

Script Timer is similar, but it runs specified AppleScripts at specified times. It's a little easier to use, but it costs $12. I would recommend just going with Cronnix (free) or crontab (also free!)

link|improve this answer
how would i use that utility to do what I am trying to do? – finiteloop Sep 13 '11 at 1:32
Do you want to add the condition: without using terminal? – GEdgar Sep 13 '11 at 1:40
No, I'm fine with using the terminal. I'd like to add the condition: without spending a great deal of time learning a command line utility. – finiteloop Sep 13 '11 at 1:43
@segfault Sorry, I was typing it up and I posted the answer before I was done. – daviesgeek Sep 13 '11 at 1:47
@daviesgeek awesome. Thanks a lot! – finiteloop Sep 13 '11 at 2:21
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.