* adjust code for cron.

This commit is contained in:
wangyidong
2015-03-13 15:10:18 +08:00
parent 2fce1a136b
commit 0d8da8c89e
2 changed files with 10 additions and 4 deletions
+2 -1
View File
@@ -3,6 +3,7 @@ $config->cron = new stdclass();
$config->cron->create = new stdclass();
$config->cron->edit = new stdclass();
$config->cron->create->requiredFields = 'm,h,dom,mon,dow,command';
$config->cron->edit->requiredFields = 'm,h,dom,mon,dow,command';
$config->cron->edit->requiredFields = 'm,h,dom,mon,dow,command';
$config->cron->maxRunDays = 8;
$config->cron->maxRunTime = 6 * 3600;
+8 -3
View File
@@ -148,10 +148,15 @@ class cron extends control
$now = new datetime('now');
foreach($parsedCrons as $id => $cron)
{
/* Skip stop and running cron.*/
$cronInfo = $this->cron->getById($id);
if(empty($cronInfo) or $cronInfo->status == 'stop' or $cronInfo->status == 'running') continue;
/* Skip empty and stop cron.*/
if(empty($cronInfo) or $cronInfo->status == 'stop') continue;
/* Skip cron that status is running and run time is less than max. */
var_dump($cronInfo->status == 'running' and (time() - strtotime($cronInfo->lastTime)) < $this->config->cron->maxRunTime);
if($cronInfo->status == 'running' and (time() - strtotime($cronInfo->lastTime)) < $this->config->cron->maxRunTime) continue;
/* Skip cron that last time is more than this cron time. */
if($cronInfo->lastTime > $cron['time']->format(DT_DATETIME1)) continue;
exit;
if($now > $cron['time'])
{
@@ -179,7 +184,7 @@ class cron extends control
}
/* Save log. */
if($output and $this->config->debug)
if($output)
{
$log = '';
$time = $now->format('G:i:s');