How to clean them (manually)? and 'clean-up' job is active and runs daily at night... (config setting is 15 days)
Announcement
Collapse
No announcement yet.
'jobs' table & 'scheduled_job_log_record' table are not cleaned (500K+ records)
Collapse
X
-
Hello,
do a simple job like this and run this each week:
PHP Code:<?php
namespace Espo\Custom\Jobs;
use Espo\ORM\Entity;
class CleanJobs extends \Espo\Core\Jobs\Base
{
public function run()
{
$GLOBALS['log']->warning( "Begin Jobs CleanJobs & Optimize");
$pdo = $this->getEntityManager()->getPDO();
$sql = "DELETE FROM scheduled_job_log_record WHERE status='Success';DELETE FROM job WHERE status='Success'";
$sth = $pdo->prepare($sql);
$sth->execute();
$sql = "SHOW TABLES";
$sth = $pdo->prepare($sql);
$sth->execute();
$allTables= $sth->fetchAll();
foreach ($allTables as $table) {
$sql = 'OPTIMIZE TABLE ' .$table[0] ;
}
$GLOBALS['log']->warning( "End Jobs CleanJobs & Optimize");
}
}
Comment