diff --git a/htdocs/install/mysql/tables/llx_cronjob.sql b/htdocs/install/mysql/tables/llx_cronjob.sql index 61036c3bd4b..a7ed4858024 100644 --- a/htdocs/install/mysql/tables/llx_cronjob.sql +++ b/htdocs/install/mysql/tables/llx_cronjob.sql @@ -33,11 +33,11 @@ CREATE TABLE llx_cronjob md5params varchar(32), module_name varchar(255), priority integer DEFAULT 0, - datelastrun datetime, - datenextrun datetime, - datestart datetime, - dateend datetime, - datelastresult datetime, + datelastrun datetime, -- date last run and when should be next + datenextrun datetime, -- job will be run if current date higher that this date + datestart datetime, -- before this date no jobs will be run + dateend datetime, -- after this date, no more jobs will be run + datelastresult datetime, lastresult text, lastoutput text, unitfrequency integer NOT NULL DEFAULT 0, diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 94bde0fb153..a26db4c3fab 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -127,9 +127,9 @@ if(is_array($object->lines) && (count($object->lines)>0)) // Loop over job foreach($object->lines as $line) { - - //If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database - if (($line->datenextrun < $now) && $line->dateend < $now){ + //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database + if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) + { $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); if ($result<0) {