Launch Daemon hack
Erica Sadun | 3:34 pm | March 5, 2008 | Admin
Jnewland suggests that you add an exit 0 line to the end of whatever script is run by the findme launch daemon. That’s a zero, not an “O”. I’ve done that to mine. I’ll let you know if this prevents the daemon from becoming cranky. I’m also still working on custom URL submission for findme and for a 30-second deadman switch that exits gracefully if web calls hang.
18 Comments »
Comment by intervex.net | March 5, 2008 | 3:41 pm
Added the exit 0 line to the end of the script per your suggestion. Do you know if it is possible for the LaunchDaemon to continue executing when the phone is suspended? I notice when the phone is locked it won’t continue updating…
Comment by shaiss | March 5, 2008 | 4:25 pm
intervex I use insomnia to solve that, although its still not 100%
exactly what does the exit 0 do?
Comment by white | March 5, 2008 | 11:20 pm
The launchd would not run when the phone is sleeping. Once it will wake up, if there is an interval missed, the launchd will run the program right away. However, it’s not the truth and there are some cases when the launchd still waits for the whole interval to run the program. It sucks, because the phone can go sleeping again not ever reaching the interval set.
The best thing you can do, without draining the battery out with insomnia (which actually prevents phone from sleeping) is have a “keeper” script, which will run every 30-60 seconds and will check for interval set. The best thing you can make the phone waking up every 15, 30 or 60 minutes is to set the Mail checking for you. Whenever the phone wakes up to check mail, the “keeper” will be started (typically within 30 seconds), checks for last launch time for findme (well, actually not findme, but “twitting” script) and starts it if the time comes or the interval is missed already.
Speaking about all other problems, there are some. The findme goes zombie sometimes, mostly because of problems with getting up with WiFi or EDGE connection. Also, curl can get posting the request or delivering the response. Most of the time this happens during driving (when the EDGE is pretty unstable or gets lost during the process). I’ve seen it stuck for several hours trying to “fetch” the response. Likely, the most of these problems can be easily fixed with shell scripting.
I’ve wrote two scripts, the keeper.sh and tweet.sh for myself, debugging them for several days already and hopefully catch the most popular flaws. They are pretty simple and use findme-muchbetter, pingwifi and curl (well, as well as few other programs of BSD subsystem). You can drop me an email to white at chief do la and I can send them to you. They are very customizable, you can set them to use your own proxy server (just in case you’re using T-Zones and can’t call the Twitter directly), as well as Twitter credentials and whatever not.
Hopefully, when I’ll get some free time, I’ll code a simple app to set all these options and run keeper from the GUI, or you can do it yourself.
Have fun.
Comment by white | March 5, 2008 | 11:25 pm
By the way, once somebody will code the simple command line tool which can run every X minutes (even waking up from sleeping) and call other program, you can get the rid of “keeper” and it will save you a pretty few battery cycles. I know the great hackers already mastered how to do this, so this is just the matter of time and willingness to do. Unfortunately, I don’t have good experience with iPhone framework. I’m pretty confident with the Unix tools, but framework will take to much of my free time.
Comment by boomersmech | March 6, 2008 | 3:05 am
Eric it fixes some of the issues but not all.. Still having the issue if you have no WIFI / EDGE (On a call) and run findme -g the bus crashes and locks the script. exit 0 has no effect being that it terminates in the middle of the script.
if this is an issue for the mean time just write a script/launch daemon that unloads and reloads your tweet launch deamon every x hours and it fixes the problem.. At lease for me.
Also I notice that afer the phone is idle for more than 15 - 20 minutes (using insomnia) the edge disconnects unless something wakes the interface ip1:.. I added ip-print to line 2 of the tweet and it takes care of that.
Comment by danvuquoc | March 6, 2008 | 8:55 am
white, could you post your script up?
Comment by white | March 6, 2008 | 12:02 pm
Okay, my scripts are at http://prokhorenko.us/white/iLoJack.zip. Feel free to use them. I put the README to archive for installation instructions. I didn’t mention setting execute permissions on them, so please, make sure findme-muchbetter, pingwifi, keeper.sh and twee.sh do have execute bit set (chmod +x ./findme-muchbetter ./pingwifi ./keeper.sh ./twee.sh). I’m also open to comments and any feedback.
Comment by white | March 6, 2008 | 12:03 pm
Damn, take the dot after the URL. The correct URL is http://prokhorenko.us/white/iLoJack.zip
Comment by shaiss | March 6, 2008 | 1:17 pm
white , could you please email me at shaiss at] gmail dot{ com?
I’m working on the server side portion of tracking so we don’t need to use tweet.
The iphone scripting is a bit above my head. Email me if your interested and lets get things moving!!!
-shai
Comment by shaiss | March 6, 2008 | 1:36 pm
emailed you white and boomersmech
Comment by white | March 7, 2008 | 4:40 pm
I’ve created the simple command line tool which takes number of minutes as command argument and makes phone awake at the set time.
You can download it here http://rapidshare.com/files/97834383/wakee.html
I can also give you source on request, but it’s extremely simple. Now you don’t have to depend on MobileMail.app mail checker
Feel free to drop me a note to w at qwe3 dot com
Comment by ramonk | March 8, 2008 | 9:52 pm
white / others–
Question (or actually 3)
– How does MobileMail.app wake up on its own? Is this method something we can copy?
– there must be some kind of wakeup daemon. See for example /var/preferences/SystemConfiguration/com.apple.AutoWake.plist
This file is auto-generated by something, and it contains (for me) the next time a calendar reminder is set. I have no clue how to add something to this (I’m a bad programmer to start and have no experience with OSX), and the Calendar Reminder wake-ups may be too much. We don’t want the backlight to come on every xx minutes… Also, they look like one time reminders.
– cron. I see there is a crond running, although I can’t see any cron jobs listed in /var/cron/tabs/root
Will cron get suspended while the system is asleep? Could we schedule something through cron rather than using the LaunchDaemon? Or am I looking at this too simplistic now?
Thanks, and THANKS ERICA for the cool util.
–Ramon
ps — what am I doing with it? I am experimenting to turn my iPhone into a Ham Radio APRS tracker, that Curls my location straight into the APRS Findu database. The purpose is to build some kind of a tracker.
Note that the submit API to the database is restricted to registered HAM Radio operators only. See the results at http://www.findu.com/cgi-bin/find.cgi?kx1t
Comment by white | March 10, 2008 | 6:59 pm
ramonk: pay more attention to comments on this site. Everything is explained. See my little wakee program above. It does the same what MobileMail.app for waking up. cron goes sleeping as well as all other programs. Well, my iPhone does not have any com.apple.AutoWake.plist files. If you have one, please, share and we’ll find out.
Comment by white | March 10, 2008 | 7:05 pm
ramonk: as for com.apple.AutoWake.plist it’s auto generated one. It reflects the actual wake up schedule. You can use my wakee program and you’ll see that the com.apple.AutoWake.plist changes as well.
Comment by z0t | March 11, 2008 | 10:47 pm
Im sure ramonk was paying attention, I believe he was asking how it works. As for an explanation please see:
http://iphonedevdocs.com/forum/showpost.php?p=1493&postcount=9
Im sure that is how white’s “wakee” program does it.
Comment by danvuquoc | March 16, 2008 | 7:41 pm
Hey white, I’ve got a question about your wakee, how are you using it? I’ve got a small script where I run
“wakee 14″ to wake up in 14 minutes…
then I immediately wakeup wifi,
sleep for 10 seconds,
call the LocateMe function as POST vars to a url of my specification…
All of this is repeated every 15 minutes via launchctl.
Should this be the correct approach?
Comment by igienger | March 19, 2008 | 9:49 pm
Heya. Just wanted to say I’ve found whitee’s approach (I’m assuming he did the same thing as me) successful. I’m using the same calls MobileMail uses to wake up the phone periodically.
Thanks to your program, I’ve been able to set up a nice visual timeline / map interface to view where I’ve been during the day (which, for today, is sadly only this apartment =P)
http://abstract.cs.washington.edu/~igienger/whereisian/history.html
Comment by ivanxx | April 24, 2008 | 10:19 am
Hi!
Just a comment for White’s wakee app. I think there’s a frightening problem with this app… It will switch the iPhone ON at the scheduled time! (well, this is the expected behavior, but if you happen to be on a taking off or landing plane…)
Is it possible to insert only a wake label in /var/preferences/SystemConfiguration/com.apple.AutoWake.plist
instead of inserting the wakepoweron?
Also, if you could accept a second parameter for a filename to be executed, perhaps all the wakeup then tweet issue would be solved?
Cheers!
Comments RSS.
Leave a comment
You must be logged in to post a comment.