This sets a cron job to run the script at midnight every night which, in turn, updates the date on the iCal icon in the dock. You'll need to keep your hard drive awake at midnight, as cron jobs won't activate on a sleeping drive.

[robg adds: You'll need to use sudo to edit the crontab file in /etc; another option is to create a crontab for your user, as explained in this hint.]

I really like AppleScript and have used it for years - but speedwise, when you put an Applescript up against a shell script - the shell script is just much faster. I try to do all my scripting in the shell - sometimes more succesful than others. Here's the same thing as above in a shell script

Good point and I actually thought of that as soon as I posted it. It might be better to use a kill -3 (quit) or kill -15 (terminate). I tried uisng kill -3 and it had no effect - but kill -15 worked fine. Does anyone know the pros and cons of doing a kill -15 on a running app?

kill -15 (SIGTERM) is the default signal sent by the kill program, allowing the program to do a clean exit, save its state, data and so on.
Kill -9 on the other hand, it only needed for hung applications, when it's not responding to anything else. The -9 (SIGKILL) signal is not catchable and the application is given no chance of saving any state or data.

To get a list of available signals, try a 'kill -l' (without quotes) in the terminal.

It's not necessary to use save this as an application, just save it as a script, and execute it with an osascript command:

/usr/bin/osascript /path/to/script

That way it doesn't pop up in the dock, and personally, I think it's faster.

It's not necessary to tell iCal to "activate", which brings it to the front. Giving it a "run" command is sufficient and lets it do it's work in the background (in case you happen to be using the computer when the script runs).

It's probably better to check whether iCal is already running, and only launch & quit it if it wasn't. It would be quite a surprise to be using iCal at midnight and have it quit all of a sudden.

This is the script I use. It has an added check to see whether it has been run yet that day so that if you have a machine that is asleep at midnight and use SleepWatcher or anacron to schedule execution, it won't run unnecessarily.

property last_run : (current date) - 1 * days -- always run the 1st time
if date string of last_run is not equal to date string of (current date) then
set last_run to current date
if not my isRunning("iCal") then
tell application "iCal"
run
quit
end tell
end if
end if
on isRunning(appName)
tell application "System Events" to return name of processes contains appName
end isRunning