Reply
Thread Tools
Posts: 486 | Thanked: 154 times | Joined on Sep 2009 @ New York City
#11
Follow up to this: basically I want to write a simple python app that gets called ever 5 minutes to collect battery statistics info and then upload it to a server to generate some cool charts (or possibly local graph gen too).
 

The Following User Says Thank You to hypnotik For This Useful Post:
Posts: 631 | Thanked: 837 times | Joined on May 2007 @ Milton, Ontario, Canada
#12
You can do this with alarmD fairly easily, or if you're not quite so picky you can do it with your python script itself... just put your code into a loop that repeats forever, and at the end of the loop (just before you start again), put a nice long sleep in.

For example:

Code:
import time

while 1:
    //Your python code goes here


   //Now we wait for 5 ( 5 minutes * 60 seconds) minutes
   time.sleep(5 * 60)
Thanks!
 

The Following User Says Thank You to jolouis For This Useful Post:
Posts: 9 | Thanked: 0 times | Joined on Dec 2009
#13
Hi, i went about writing a new event object for alarmd, but how would i go about executing the test file?

do i just do "/usr/sbin/alarmd filename"?

Thanks.

Last edited by markedsword; 2009-12-11 at 16:11.
 
Posts: 543 | Thanked: 181 times | Joined on Aug 2009 @ Universe,LocalCluster.MilkyWay.Sol.Earth.Europe.Slovenia.Ljubljana
#14
Myself I just compile fcron for the n900 and use that. Wouldn't mind seeing an acron aka alarm cron but for now this solution works for me. The cron daemon sleeps between runs and has a bootrun option to run anything it might have missed inbetween. I do get some odd behaviour from time to time like cronjobs not starting so need to look a bit into it.
 
Posts: 486 | Thanked: 251 times | Joined on Oct 2009
#15
Originally Posted by jolouis View Post
You can do it with your python script itself... just put your code into a loop that repeats forever, and at the end of the loop (just before you start again), put a nice long sleep in.
At the tiny cost of a little math, you can have the code run at relatively precise intervals instead of gradually drifting by the execution time of the code itself. You can execute immediately the first time by putting the sleep at the bottom of the loop, or always on the even time boundary by putting the sleep at the bottom.

This is so simple because of the properties of the modulo function and that days, hours, minutes, and seconds are all integer multiples of each other. Use something like 10, 15, or 60 instead of 300 if you don't want to wait 5 minutes. To run once an hour on the hour, use 3600. Add an offset before the last ")" in the sleep function to start at a fixed time after an even time boundary.
Code:
import time

while 1:
    # Now we wait for the next 5 minute boundary
    time.sleep(300 - time.time()%300)
    # Your python code goes here,
    # all the following lines are just an example
    t = time.time()
    ts = time.localtime(t)
    print t
    print ts
    print time.asctime(ts)
 
Posts: 55 | Thanked: 14 times | Joined on Mar 2009 @ UK
#16
Originally Posted by markedsword View Post
Hi, i went about writing a new event object for alarmd, but how would i go about executing the test file?

do i just do "/usr/sbin/alarmd filename"?

Thanks.
I tracked down some docs here:

http://maemo.org/development/documen...nterface_bora/

Rgrds

Peter
 
Reply


 
Forum Jump


All times are GMT. The time now is 08:46.