How to set up your iPhone for scheduled reboot

Some people may notice that their iPhones start to get a little sluggish or start showing some unexpected behaviour when they’re running them for multiple days or even weeks without a reboot. So I asked myself, is there a way to make the iPhone reboot regularly? Is there some kind of cron daemon?

So I google’d a bit and found out that some people mention a cron daemon indeed, but there was no “crontab” command on my iPhone and I couldn’t find it on cydia either. But also, people said that cron on the iPhone has a – for my case, anyway – major flaw: It does not work while the phone is asleep. Now I want to make my iPhone reboot at night, when I’m asleep, so my phone will be asleep too.
Enter LaunchDaemons. Some people say it works while asleep, some say it doesn’t, I have yet to find out, but it looks quite promising. launchd is Apple’s own implementation of cron jobs, and it works with – you might have guessed it – property list files (.plist). Love them or hate them, I hacked one together that works.

First things first. For this you need to be jailbroken, because you need SSH access to your phone. The plist file needs to be copied to /System/Library/LaunchDaemons/ (or you copy it somewhere else and link it to that directory). My file is called com.Jay2k1.reboot.plist and looks like this:

<?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.Jay2k1.reboot</string>
	<key>ProgramArguments</key>
	<array>
		<string>/sbin/reboot</string>
	</array>
	<key>StartCalendarInterval</key>
	<dict>
		<key>Hour</key>
		<integer>05</integer>
		<key>Minute</key>
		<integer>10</integer>
	</dict>
</dict>
</plist>

In the lower part, you can set hour and minute (in my case, 05:10 AM). If you don’t want it to happen every day, you can add other key/integer pairs, like “Day”, “Weekday” and “Month”. For further information, check Apple’s launchd page.

After you have copied the plist file to its destination, you have to manually reboot the iphone. If you’re still connected via ssh (as root), you can just type reboot and it’ll reboot. If not, the plist file won’t work anyway, it uses the reboot binary in /sbin/.

Now it should work. I tested it with a time that was about five minutes in the future, saved that time to the plist file, rebooted the iphone, started a bunch of apps and then pressed the sleep button. One or two minutes after, the phone rebooted, so I’m confident it will work. I’ll update when I know for sure.

3 Comments

    1. Hi Nick, I’m afraid I can’t help with current iPhones and iOS versions, because I switched to the dark side (Android) two years ago. Sorry

Leave a Reply

Your email address will not be published. Required fields are marked *