x

CRON JOB - VTIGER

Decrease The Run Time Of CRON JOB (15 mins to 1 min)

In this document we decrease the runtime of CRON Job in vtiger.

Follow these simple steps and you can set runtime as per your need.

STEP1. First of all you need to set the minimum frequency value in config.inc.php file.

For this go to include\utils\utils.php

Find :-

function getMinimumCronFrequency() {

global $MINIMUM_CRON_FREQUENCY;

if(!empty($MINIMUM_CRON_FREQUENCY)) {

return $MINIMUM_CRON_FREQUENCY;

}

return 15;

}

Change the value there as per your need.

Right now we change this value as 1.

So, for this

function getMinimumCronFrequency() {

global $MINIMUM_CRON_FREQUENCY;

if(!empty($MINIMUM_CRON_FREQUENCY)) {

return $MINIMUM_CRON_FREQUENCY;

}

return 1;

}

After this step you can change the cron scheduler time.

For this go to Settings -> CRM Settings -> Automation -> Scheduler.

Now, you can see the Cron Job scheduler list. To change the scheduler time you need to select one cron job for example we select Workflow.

image1

Then change the frequency as 1 for 1 minute.

image2

Click on Save Button.

Step2. After that, you need to change the Cron.php file.

For this go to \ vtlib\Vtiger\Cron.php

Find -

function isRunnable() {

$runnable = false;

if (!$this->isDisabled()) {

// Take care of last time (end - on success, start - if timedout)

// Take care to start the cron im

$lastTime = ($this->getLastStart() > 0) ? $this->getLastStart() : $this->getLastEnd();

$elapsedTime = time() - $lastTime;

$runnable = ($elapsedTime >= ($this->getFrequency()-60));

}

return $runnable;

}

Replace with –

function isRunnable() {

$runnable = false;

return true;

if (!$this->isDisabled()) {

// Take care of last time (end - on success, start - if timedout)

// Take care to start the cron im

$lastTime = ($this->getLastStart() > 0) ? $this->getLastStart() : $this->getLastEnd();

$elapsedTime = time() - $lastTime;

$runnable = ($elapsedTime >= ($this->getFrequency()-60));

}

return $runnable;

}

Tags