Run Quick Repair Automatically with Scheduler

Iā€™m looking for a way to run the quick repair tool automatically. Is that possible using the scheduler? If so, is there documentation on how to add this core out-of-the-box feature to the scheduler?

Thanks.

Versions:
SuiteCRM 7.10.7
PHP 7.2
SQL Server 2014
Windows Server 2012 R2

you need to add a new job , let it call ā€œoutright_do_repairā€.

and put this function at custom/Extension/application/Ext/Utiils/outright_do_repair.php

function outright_do_repair(){
require_once(ā€œmodules/Administration/QuickRepairAndRebuild.phpā€);
global $moduleList;
$repair = new RepairAndClear();
$repair->repairAndClearAll(array(ā€œclearAllā€),$moduleList, true,false);
$exit_on_cleanup = true;
sugar_cleanup(false);
}

Thank you for your reply. If I add this function to the new php file in that directory, how am I scheduling this function to run every night? Are you also saying that I would need to download your plugin and install into my SuiteCRM instance to do this?

I already gave you complete function , so no need to install, you may follow this article.

Cron job by code

The correct way to Add the Repair Function that would be available for you in the Schedulers Module is to add the Function Definition in the following File.

custom\Extension\modules\Schedulers\Ext\ScheduledTasks\CustomRepairRebuild.php

Now in this File define the function as

<?php

$job_strings[] = 'CustomRepairRebuild';

function CustomRepairRebuild{
    require_once("modules/Administration/QuickRepairAndRebuild.php");
     global $moduleList;
     $repair = new RepairAndClear();
     $repair->repairAndClearAll(array("clearAll"),$moduleList, true,false);
     $exit_on_cleanup = true;
     sugar_cleanup(false);
    return true;
}

Now create a Language String for this function at

custom/Extension/modules/Schedulers/Ext/Language/en_us.CustomRepairRebuild.php

The content would be


<?php

$mod_strings['LBL_CUSTOMRREPAIRREBUILD'] = 'Custom Repair Rebuild Function';

After these changes, if you run Quick Repair/Rebuild and navigate to Scheduler module from Admin. Add a New Scheduler Job and you will see ā€˜Custom Repair Rebuild Functionā€™ as a job to be run and configured as per your settings.

Thank you. I will try and let you know how it goes.