Re: cronjobs
Ben, Than you so much, this really is what i needed. If i have put it together with some scripts i will put it on the wiki. This way we can wake-up our FR when a cron job is due. Again thanks a lot. Kind regards, Ed Ben Wong wrote: Sure, I've whipped up an example for you based on the documentation located here: http://search.cpan.org/dist/Schedule-Cron/lib/Schedule/Cron.pm --Ben #!/usr/bin/perl -w use Schedule::Cron; # Dummy subroutine, to make Cron constructor happy. sub dispatcher { print ID: ,shift,\n; print Args: ,@_,\n; } my $cron = new Schedule::Cron(\dispatcher); # You can print out a date from a single line... $line='*/5 3 * * 5,6'; print The crontab entry '$line' will be next executed on ; print scalar(localtime($cron-get_next_execution_time($line))); print \n\n; # ...or you can iterate through a crontab file. $cron-load_crontab(/etc/crontab); my @entries = $cron-list_entries(); foreach $e (@entries) { # time in original cron format, */5 * * * * print $$e{'time'} . \t; my $nexttime=$cron-get_next_execution_time($$e{'time'}); # time in seconds since the epoch print $nexttime . \t; # time in human readable format print scalar(localtime($nexttime)) . \t; # the rest of the line from the crontab file @command = $$e{'args'}; print $command[0][0]; print \n; } # END OF SCRIPT On Sat, May 30, 2009 at 6:29 PM, Ed Kapitein e...@kapitein.org wrote: Ben Wong wrote: Did you try $cron-get_next_execution_time($cron_entry,[$ref_time]) ? --Ben No, i had no idea i could ! But now that i try it i get: Can't call method get_next_execution_time on an undefined value at ./ff.pl line 11. Can you make an example perl script? a real simple one? Thanks ! Kind regards, Ed On Sat, May 30, 2009 at 4:21 PM, Ed Kapitein e...@kapitein.org wrote: Alexey Feldgendler wrote: On Fri, 29 May 2009 15:49:27 +0200, Ed Kapitein e...@kapitein.org wrote: i need a script/program that will read a crontab line ( * * * * * some_action) and output the date and time the job will run. Does anyone know of such a tool? This way i can un-suspend the FR a few seconds prior to the start of that cron job. I already made a script that sort of works, but it is limmited at best and i hate to reinvent the wheel again. You might want to look at this: http://search.cpan.org/dist/Schedule-Cron Hi Alexey and all the others I did take a look at perl, but i am a real perl noob. This is what i have so far: #!/usr/bin/perl use Config::Crontab $event = new Config::Crontab::Event( -data = '*/5 3 * * 5,6 /bin/blech' ); print $event-minute . \n; print $event-hour . \n; print $event-dom . \n; print $event-datetime . \n; print $event-command . \n; print $event-dump . \n; And if i run that i get: */5 3 * */5 3 * * 5,6 /bin/blech */5 3 * * 5,6 /bin/blech Perhaps i am missing the obvious here. Is there someone out there who can make a script that can read a crontab line and give the time and date of the next time it will be executed ? output in the form: secs_since_epoch,-mm-dd,hh:mm,command would be *great* Many thanks in advance, Ed ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: cronjobs
Alexey Feldgendler wrote: On Fri, 29 May 2009 15:49:27 +0200, Ed Kapitein e...@kapitein.org wrote: i need a script/program that will read a crontab line ( * * * * * some_action) and output the date and time the job will run. Does anyone know of such a tool? This way i can un-suspend the FR a few seconds prior to the start of that cron job. I already made a script that sort of works, but it is limmited at best and i hate to reinvent the wheel again. You might want to look at this: http://search.cpan.org/dist/Schedule-Cron Hi Alexey and all the others I did take a look at perl, but i am a real perl noob. This is what i have so far: #!/usr/bin/perl use Config::Crontab $event = new Config::Crontab::Event( -data = '*/5 3 * * 5,6 /bin/blech' ); print $event-minute . \n; print $event-hour . \n; print $event-dom . \n; print $event-datetime . \n; print $event-command . \n; print $event-dump . \n; And if i run that i get: */5 3 * */5 3 * * 5,6 /bin/blech */5 3 * * 5,6 /bin/blech Perhaps i am missing the obvious here. Is there someone out there who can make a script that can read a crontab line and give the time and date of the next time it will be executed ? output in the form: secs_since_epoch,-mm-dd,hh:mm,command would be *great* Many thanks in advance, Ed ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: cronjobs
Did you try $cron-get_next_execution_time($cron_entry,[$ref_time]) ? --Ben On Sat, May 30, 2009 at 4:21 PM, Ed Kapitein e...@kapitein.org wrote: Alexey Feldgendler wrote: On Fri, 29 May 2009 15:49:27 +0200, Ed Kapitein e...@kapitein.org wrote: i need a script/program that will read a crontab line ( * * * * * some_action) and output the date and time the job will run. Does anyone know of such a tool? This way i can un-suspend the FR a few seconds prior to the start of that cron job. I already made a script that sort of works, but it is limmited at best and i hate to reinvent the wheel again. You might want to look at this: http://search.cpan.org/dist/Schedule-Cron Hi Alexey and all the others I did take a look at perl, but i am a real perl noob. This is what i have so far: #!/usr/bin/perl use Config::Crontab $event = new Config::Crontab::Event( -data = '*/5 3 * * 5,6 /bin/blech' ); print $event-minute . \n; print $event-hour . \n; print $event-dom . \n; print $event-datetime . \n; print $event-command . \n; print $event-dump . \n; And if i run that i get: */5 3 * */5 3 * * 5,6 /bin/blech */5 3 * * 5,6 /bin/blech Perhaps i am missing the obvious here. Is there someone out there who can make a script that can read a crontab line and give the time and date of the next time it will be executed ? output in the form: secs_since_epoch,-mm-dd,hh:mm,command would be *great* Many thanks in advance, Ed ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: cronjobs
Ben Wong wrote: Did you try $cron-get_next_execution_time($cron_entry,[$ref_time]) ? --Ben No, i had no idea i could ! But now that i try it i get: Can't call method get_next_execution_time on an undefined value at ./ff.pl line 11. Can you make an example perl script? a real simple one? Thanks ! Kind regards, Ed On Sat, May 30, 2009 at 4:21 PM, Ed Kapitein e...@kapitein.org wrote: Alexey Feldgendler wrote: On Fri, 29 May 2009 15:49:27 +0200, Ed Kapitein e...@kapitein.org wrote: i need a script/program that will read a crontab line ( * * * * * some_action) and output the date and time the job will run. Does anyone know of such a tool? This way i can un-suspend the FR a few seconds prior to the start of that cron job. I already made a script that sort of works, but it is limmited at best and i hate to reinvent the wheel again. You might want to look at this: http://search.cpan.org/dist/Schedule-Cron Hi Alexey and all the others I did take a look at perl, but i am a real perl noob. This is what i have so far: #!/usr/bin/perl use Config::Crontab $event = new Config::Crontab::Event( -data = '*/5 3 * * 5,6 /bin/blech' ); print $event-minute . \n; print $event-hour . \n; print $event-dom . \n; print $event-datetime . \n; print $event-command . \n; print $event-dump . \n; And if i run that i get: */5 3 * */5 3 * * 5,6 /bin/blech */5 3 * * 5,6 /bin/blech Perhaps i am missing the obvious here. Is there someone out there who can make a script that can read a crontab line and give the time and date of the next time it will be executed ? output in the form: secs_since_epoch,-mm-dd,hh:mm,command would be *great* Many thanks in advance, Ed ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
cronjobs
Hi all, i need a script/program that will read a crontab line ( * * * * * some_action) and output the date and time the job will run. Does anyone know of such a tool? This way i can un-suspend the FR a few seconds prior to the start of that cron job. I already made a script that sort of works, but it is limmited at best and i hate to reinvent the wheel again. Kind regards, @ ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: cronjobs
On Fri, 29 May 2009 15:49:27 +0200, Ed Kapitein e...@kapitein.org wrote: i need a script/program that will read a crontab line ( * * * * * some_action) and output the date and time the job will run. Does anyone know of such a tool? This way i can un-suspend the FR a few seconds prior to the start of that cron job. I already made a script that sort of works, but it is limmited at best and i hate to reinvent the wheel again. You might want to look at this: http://search.cpan.org/dist/Schedule-Cron/ -- Alexey Feldgendler ale...@feldgendler.ru [ICQ: 115226275] http://feldgendler.livejournal.com ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community