I love my 2nd Generation AppleTV. Sure, it doesn’t have 1080p but for the money (it was a gift) it sure is awesome.
The first thing I did with my AppleTV was jailbreak it. Once jailbroken I could install the PlexTV client. This allows me to stream any content from my Mac to the AppleTV. What I do with this is the subject of another post.
However, the AppleTV isn’t perfect. Recent versions of either the AppleTV software or the Jailbreak software causes periodic playback errors when playing back content from Netflix or the PlexTV client.
The only way to fix these errors is to reboot the AppleTV. This is a pain to do when ready to sit down and watch something. The obvious solution? Schedule reboots with launchctl.
Launchctl is a swiss army knife utility that replaces a number of Unix utilities including CRON.
LaunchCtl scripts are Property List files. These are just specially formatted XML files saved with the extension .plist
Navigate to your /Library/LaunchDaemons folder on your AppleTV, open up the nano editor and type the following:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.joe.reboot</string> <key>ProgramArguments</key> <array> <string>/sbin/reboot</string> </array> <key>StartCalendarInterval</key> <!-- reboot every day at 3:12am --> <dict> <key>Hour</key> <integer>3</integer> <key>Minute</key> <integer>12</integer> </dict> </dict> </plist>
If you’ve never seen a launchctl script before this might seem like gibberish.
LaunchCtl scripts consist of key value pairs indicated with . Most of it is boilerplate. I’ll talk about the ones relevant to us here.
- Label – this argument matches the name of the plist file. You can call it whatever you want, you just need to give the plist file the same name. In this example, the plist file name is com.joe.reboot.plist
- ProgramArguments – this takes a string indicating the path and filename of the program that needs to run.
- StartCalendarInterval – this takes a dictionary with date and time information. In this example I set Hour and Minute and ignore any of the other date keys.
Save all of this as a plist file.
Load the plist file
The next step is to load the plist file into launchctl. Type the following in the console:
launchctl load /Library/LaunchDaemons/com.joe.reboot.plist
Then, if you want to test your plist file you can type:
launchctl start com.joe.reboot
If everything works, you should get disconnected from the console as your AppleTV reboots.
There are a lot more things you can do with launchctl. This solved my network error problems while I wait for an update to the jailbrake tools.
If you have any cool uses for a jailbroken AppleTV, share them in the comments.