'jobs' table & 'scheduled_job_log_record' table are not cleaned (500K+ records)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bill
    Member
    • Aug 2019
    • 57

    'jobs' table & 'scheduled_job_log_record' table are not cleaned (500K+ records)

    How to clean them (manually)? and 'clean-up' job is active and runs daily at night... (config setting is 15 days)
  • item
    Active Community Member
    • Mar 2017
    • 1480

    #2
    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");
        }
    }
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • yuri
      Member
      • Mar 2014
      • 8510

      #3
      They actually are being cleaned up.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      Working...