From 51f12b4ce80407df673d2c285d518d72f7609480 Mon Sep 17 00:00:00 2001 From: rylon Date: Thu, 20 Nov 2014 13:56:39 +0100 Subject: [PATCH] cron fixes, time is now based on last run not now() --- cron/cron.php | 11 ++++++----- cron/crontime.php | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cron/cron.php b/cron/cron.php index 54303f0..7e73d90 100644 --- a/cron/cron.php +++ b/cron/cron.php @@ -41,11 +41,12 @@ class cron { if(!self::check($cron[\SYSTEM\DBD\system_cron::FIELD_CLASS])){ throw new \SYSTEM\LOG\ERROR("Given class is not a cronjob");} //time - return \SYSTEM\CRON\crontime::next_now( $cron[\SYSTEM\DBD\system_cron::FIELD_MIN], - $cron[\SYSTEM\DBD\system_cron::FIELD_HOUR], - $cron[\SYSTEM\DBD\system_cron::FIELD_DAY], - $cron[\SYSTEM\DBD\system_cron::FIELD_DAY_WEEK], - $cron[\SYSTEM\DBD\system_cron::FIELD_MONTH]); + return \SYSTEM\CRON\crontime::next( strtotime($cron[\SYSTEM\DBD\system_cron::FIELD_LAST_RUN]), + $cron[\SYSTEM\DBD\system_cron::FIELD_MIN], + $cron[\SYSTEM\DBD\system_cron::FIELD_HOUR], + $cron[\SYSTEM\DBD\system_cron::FIELD_DAY], + $cron[\SYSTEM\DBD\system_cron::FIELD_DAY_WEEK], + $cron[\SYSTEM\DBD\system_cron::FIELD_MONTH]); } private static function status($class, $status){ diff --git a/cron/crontime.php b/cron/crontime.php index 03f9dda..ccaac15 100644 --- a/cron/crontime.php +++ b/cron/crontime.php @@ -20,6 +20,9 @@ class crontime { $day_week = $day_week % 6; // 7 and 0 both mean Sunday $now_day_week = $now_day_week % 6; // 7 and 0 both mean Sunday $next_day += abs($day_week - $now_day_week);} + new \SYSTEM\LOG\INFO(print_r(array($base_time,$min,$hour,$day,$day_week,$month),true)); + new \SYSTEM\LOG\INFO(print_r(array($now_min, $now_hour, $now_day, $now_month, $now_day_week),true)); + new \SYSTEM\LOG\INFO(print_r(array($next_hour, $next_min, 0, $next_month, $next_day, $next_year),true)); return mktime($next_hour, $next_min, 0, $next_month, $next_day, $next_year); } public static function last($base_time,$min,$hour,$day,$day_week,$month){