5 second cron
Gus Wirth
gwirth79 at gmail.com
Wed Mar 31 23:35:49 PDT 2010
On 03/31/2010 10:47 PM, David Brown wrote:
> On Wed, Mar 31, 2010 at 10:33:42PM -0700, Gus Wirth wrote:
>
>> Has anyone heard of an application that does such a thing? It would have
>> to run on the embedded systems, so Perl and Python are out.
>
> How about this? I don't imagine you could do it with much less code.
>
> #include <sys/time.h>
> #include <stdio.h>
>
> int main(int argc, char **argv)
> {
> struct timeval tm;
> struct timespec ts;
>
> gettimeofday(&tm, NULL);
> ts.tv_sec = 4 - (tm.tv_sec % 5);
> ts.tv_nsec = 1000 * (1000000 - tm.tv_usec);
> /*printf("sec %d, usec %d\n", ts.tv_sec, ts.tv_nsec);*/
> nanosleep(&ts, NULL);
> }
>
>
Cool! A program that sleeps a variable amount of time and then exits on
the 5's. I think I'll call it wait5 because if I called it the
dave_brown5 they would think it was a musical group thing :) Now to
figure out how to get the cross-compiler stuff going again.
Gus
More information about the KPLUG-List
mailing list