Subject: | Adding the ability to delete a CronTab entry automatically specifying a repeatcounter |
Date: | Tue, 27 Aug 2013 01:38:15 +0200 |
To: | <bug-Schedule-Cron [...] rt.cpan.org> |
From: | "Juergen Arlt" <pc [...] scj-arlt.de> |
Schedule-Cron Wishlist 1.01
nofork - mode
Perl v5.16.2
Certain Cron entries are only supposed to be executed only one time or a
limited amount of times. It would be possible to add these entries with the
appropriate timer record but over time the Cron tab could be very crowded.
Therefore it is useful to delete the Cron entries that are executed already
the number of times that they are supposed to run.
It could be done by another reoccurring task that would clean up these
tasks. However that is difficult as each task would have to mark somewhere
how often it was run already either in any related variable or in an
attribute of the task itself. Modifying the own attributes is not easy as
the task would need to figure out it's own index (which I did not find how
to get from within the task)
sub dispatcher { print "ID: ",shift,"\n"; } - only prints the first
argument - not the index.
Another option would be for the task to remove itself from the Cron entries
but again the task would need its own index from the Cron tab and any
attribute where the number of executions is specified.
An easier solution would be to add a named parameter e.g. 'repeatcounter' =>
5 in the $cron->add_entry that is decremented with every job run and when 0
is reached the job is automatically removed from the Cron Tab.
Hope that a feature like this could be integrated into the great program.
Regards
Juergen