ra93013 has asked for the wisdom of the Perl Monks concerning the following question:
I using Schedule::Cron I'd like to determine the next excecution time in a detached process and write the time to a file. When $cron->get_next_execution_time(EVERY_MINUTE) runs in the subroutine UpdateFileOne I get the error Undefined subroutine &main::UpdateFile called at /usr/local/share/perl5/Schedule/Cron.pm line 1257. What I'm I doing wrong?
#!/usr/bin/perl use strict; use Schedule::Cron; use constant { EVERY_MINUTE => '*/1 * * * *' , EVERY_TEN_MINUTE => '0,10,20,30,40,50 * * * *' , EVERY_TEN_MINUTE_OFFSET => '3,23,25,35,45,55 * * * *' }; #Glolbal ##########*******************#################### our $cron = new Schedule::Cron(\&UpdateFile,'processprefix' => 'Index +Move'); our $cronId; #MAIN PROGRAM ##########*******************#################### $cronId = $cron->add_entry(EVERY_MINUTE,{'subroutine' => ,\&UpdateFile +One, 'arguments' => ["Passed"]}); $cronId = $cron->add_entry(EVERY_TEN_MINUTE_OFFSET, {'subroutine' => , +\&UpdateFileTen, 'arguments' => ["Passed"]}); sub UpdateFileOne { my $outputfile= '/home/allenrj1/scripts/updatefile.txt'; my $timestamp = localtime(time); my $passed_argument = $_[0]; my $next_time = $cron->get_next_execution_time('*/1 * * * *'); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($ +next_time); open MYFILE, ">>$outputfile" or die "problem opening $outputfile\n"; print MYFILE "Ran at $timestamp with $passed_argument\n"; printf "Next Time is: %02d:%02d:%02d\n", $hour,$min,$sec; close(MYFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Schedule::Cron determine next run time
by kcott (Archbishop) on Mar 03, 2014 at 19:37 UTC | |
|
Re: Schedule::Cron determine next run time
by talexb (Chancellor) on Mar 03, 2014 at 19:08 UTC | |
by kcott (Archbishop) on Mar 03, 2014 at 19:43 UTC |