Rebooting an Airport Extreme via AppleScript.
November 29, 2008 at 11:13 pm | In AppleScript, Geeky, Mac OS X | 4 CommentsAfter the latest firmware update for my saucer-shaped Airport Extreme base station, I’ve found myself rebooting my Airport on a much more regular basis than I had before. Before the update, I was rebooting it once in a blue moon. Now, I’m rebooting it once every couple of days. The routine goes something like this:
*Get home*
*Wife fires up her laptop*
“Honey, the internet’s broken.”
*I trudge down to my basement office and power-cycle the base station*
*Walk back up*
“Is it working now?”
“Yup.”
This got old fast, so I started thinking about ways to reboot my Airport base station nightly, preferably without human involvement. A quick Google showed surprisingly few people trying to accomplish this, but the nice folks who had also posted their AppleScripts. I’m hardly an AppleScript master, but I was able to pull together the following script using this entry from MacOSXHints, as well as this one from David Chan.
———–
tell application "AirPort Utility" to activate delay 2 tell application "System Events" tell application process "AirPort Utility" tell window 1 click button "Manual Setup" delay 60 end tell tell menu bar 1 click menu bar item "Base Station" tell menu bar item "Base Station" tell menu 1 click menu item "Restart…" end tell end tell end tell delay 1 --imperative delay 30 end tell end tell tell application "AirPort Utility" to quit
———–
I later added the ability to log to a file in ~/Library/Logs by using this additional script from MacOSXHints, so my current script looks like this:
———–
set commonScript to load script alias ¬
((path to library folder from user domain as string) ¬
& "Scripts:Common code.scpt")
tell application "AirPort Utility" to activate
delay 2
tell application "System Events"
tell application process "AirPort Utility"
tell window 1
click button "Manual Setup"
delay 60
end tell
tell menu bar 1
click menu bar item "Base Station"
tell menu bar item "Base Station"
tell menu 1
click menu item "Restart…"
end tell
end tell
end tell
delay 1 --imperative
delay 30
end tell
end tell
tell application "AirPort Utility" to quit
log_event("Basement Airport Extreme restarted") of commonScript
———–
The last piece of the puzzle was figuring out how to trigger it, but iCal came to the rescue. Maria Langer posted a good write-up on how to do this up on her site, which I was able to use to help me set up a recurring appointment at 12:00 AM every day to reboot the Airport, with the alarm for the event triggering the script that actually reboots the Airport.
4 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

Glad you found my script helpful!
Comment by David Chan — November 30, 2008 #
And I’m glad you found my iCal scheduling trick helpful! I use it for all kinds of things. Most recently, I set it up to
But here’s dumb question: why not simply attach the power cord of the AirPort base station to a light timer with a short delay between power down and power up? Would that mess up the base station’s innards? I hope not, because that’s how I reset mine when it stops working.
Comment by Maria — December 1, 2008 #
Maria,
I set it up this way because it was a fun project during a long weekend and the box that handles the reboot is up all of the time anyway, performing a different job in addition to rebooting my Airport.
Comment by rtrouton — December 1, 2008 #
[...] February 6, 2009 at 6:39 pm | In Uncategorized | Back in November, I’d posted this entry describing how I’d started rebooting my Airport Extreme on a nightly basis to fix a problem [...]
Pingback by Airport Extreme update: Rebooting nightly wasn’t the answer. « Der Flounder — February 6, 2009 #