How can I configure my computer to run an AppleScript at a specific time? Caveat: without using iCal
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!)
In recent versions of OS X launchd
is preferred to cron
. Here's an excerpt from man crontab
under Mavericks:
Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands.
You can control launchd
using the built-in launchctl
but many people (including me) use a GUI called Lingon.
UPDATE: I now use LaunchControl instead of Lingon. It's a lot more powerful, though the interface is more complicated.