It has been an obssession of mine to reboot routers on a routine basis.  I’m not sure why I do it, but it makes me believe that the router is kept “fresh” and will continue to perform optimally.  Maybe I am just used to running Windows (where you will need to reboot the machine every once in a while).

Anyways, I wrote hacked together a simple AppleScript (note: this is my first AppleScript ever written) which simulates menu clicks in the AirPort Utility to restart my Time Capsule.  The script doesn’t choose which Apple wireless device to restart, as I only have one – the Time Capsule.  If you want to use the script and you have multiple wireless base stations (eg. an AirPort Express), you may have to modify the script to choose which one to manipulate.

Here is the simple AppleScript:

tell application "AirPort Utility"
	activate
end tell
 
tell application "System Events"
	delay 10
	click menu item "Manual Setup" of menu "Base Station" of menu bar 1 of process "AirPort Utility"
	delay 5
	click menu item 6 of menu "Base Station" of menu bar 1 of process "AirPort Utility"
	delay 5
	click menu item "Close" of menu "File" of menu bar 1 of process "AirPort Utility"
end tell

With this script saved, I scheduled it to run automatically every week. Of course you can use cron and set this script as a scheduled job, but why do that when you can use iCal?  Here’s a thousand words on how to set the script to run automatically:

Adding an AppleScript alert in iCal

You may never have a need to restart your Time Capsule automatically, but if you do, this should give you a starting point on how to go about doing that.

Share

8 Responses to “How to: automatically restart Time Capsule (AppleScript/iCal)”

[...] – bookmarked by 4 members originally found by jgyoungmd on 2008-09-14 How to: automatically restart Time Capsule (AppleScript/iCal) http://adavidchan.com/how-to-automatically-restart-time-capsule-applescriptical/ – bookmarked by 1 [...]

Pingback by Bookmarks about Applescript — October 4, 2008 @ 3:15 am

[...] but I was able to pull together the following script using this entry from MacOSXHints, as well as this one from David [...]

How would you modify this script to select a specific airport? I have searched high and low and no one has documented this and I have no experience writing scripts. Thanks david

Comment by David Sterling — January 2, 2010 @ 8:37 am

As the airports are listed in alpha order I added a number of these:

key code 125

which is just a down arrow keystroke… Not sure how to do it any other way.

Comment by Rob S — January 8, 2010 @ 2:24 am

nice script– my backups to TC were constantly failing once a day- and I got tired of troubleshooting without a fix-

All I knew when I rebooted TC– all was good-

My only problem is that airport utility stays open after script runs- I tried to add
delay 5
quit

at the end- but it left me with TC not able to backup again-

So is this the correct commant to close down airport utility???

Comment by dave — September 22, 2010 @ 6:59 am

Some mothers do have em

Comment by Clementine Hoglund — July 19, 2011 @ 2:05 am

This is the script I’m using edited from yours and I’m assuming after “click menu ‘Base Station”" that line you could use the “key code 125″ to choose which AirPort/Time Capsule you are looking to restart.

I also had to enable “access for assistive devices” under the Universal Access panel under System Preferences.

tell application “AirPort Utility”
activate
end tell

tell application “System Events”
delay 10
click menu “Base Station” of menu bar 1 of process “AirPort Utility”
key code 125
key code 125
key code 125
key code 125
key code 36
delay 5
end tell

tell application “AirPort Utility”
quit
end tell

Comment by Russ — October 17, 2011 @ 3:11 am

cheap to take huge discount for gift

Comment by Utilkgarth — December 11, 2011 @ 12:29 am

leave a reply?