From 54752ca6a56220522fb859148a76c2095acd7f78 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 9 Feb 2016 15:12:50 +0100 Subject: [PATCH] Changed cron execution to be executed one time at least TICKETS #3329 --- pandora_agents/unix/pandora_agent | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index ae074ef116..dc7c142bbf 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1673,12 +1673,27 @@ sub check_module_cron ($) { # Get interval my ($bottom, $top) = split (/-/, $cron_params[$i]); $top = $bottom unless defined ($top); + + # Check if next execution will overflow the cron (only minutes overflow) + # If overflow, execute the module + my $overflow_cron = 0; + if ($i == 0) { + my $start_cron_seconds = $bottom*60; + my $current_exec_seconds = $time_params[$i]*60; + my $next_exec_seconds = $time_params[$i]*60 + $module->{'interval'}*$Conf{'interval'}; + if ($current_exec_seconds > $start_cron_seconds && $current_exec_seconds > $next_exec_seconds) { + $start_cron_seconds += 3600; + } + if (($current_exec_seconds <= $start_cron_seconds) && ($start_cron_seconds <= $next_exec_seconds)) { + $overflow_cron = 1 + } + } # Check interval if ($bottom <= $top) { - return 0 if ($time_params[$i] < $bottom || $time_params[$i] > $top); + return 0 if (($time_params[$i] < $bottom || $time_params[$i] > $top) && !$overflow_cron); } else { - return 0 if ($time_params[$i] < $bottom && $time_params[$i] > $top); + return 0 if (($time_params[$i] < $bottom && $time_params[$i] > $top) && !$overflow_cron); } }