From ee96a4381fa187eede8374601d0c06cd861eb66c Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 18 Oct 2009 09:15:08 +0200 Subject: Multi::Maintenance: Fixed bug with cron jobs running more than once --- lib/Multi/Maintenance.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm index 423def75..59d30ce6 100644 --- a/lib/Multi/Maintenance.pm +++ b/lib/Multi/Maintenance.pm @@ -50,7 +50,7 @@ sub set_daily { # (GMT because we're calculating on the UNIX timestamp, I can easily add an # offset if necessary, but it doesn't really matter what time this cron # runs, as long as it's run on a daily basis) - $_[KERNEL]->alarm(daily => int(time/86400+1)*86400); + $_[KERNEL]->alarm(daily => int((time+3)/86400+1)*86400); } @@ -70,7 +70,7 @@ sub set_monthly { # We do this by simply incrementing the timestamp with one day and checking gmtime() # for a month change. This might not be very reliable, but should be enough for # our purposes. - my $nextday = int(time/86400+1)*86400; + my $nextday = int((time+3)/86400+1)*86400; my $thismonth = (gmtime)[5]*100+(gmtime)[4]; # year*100 + month, for easy comparing $nextday += 86400 while (gmtime $nextday)[5]*100+(gmtime $nextday)[4] <= $thismonth; $_[KERNEL]->alarm(monthly => $nextday); -- cgit v1.2.3