Skip to content

Commit b9d155b

Browse files
committed
cron logs cleaner
1 parent b666595 commit b9d155b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app/site/cron_tasks/DbManager.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,15 @@ public function dumpDB()
5050
->useCompressor(new GzipCompressor())
5151
->dumpToFile(App::getDir(App::DUMPS).DS.'dump.'.date("Ymd_His").'.sql.gz');
5252
}
53+
54+
/**
55+
* remove cron logs older than 12 hours
56+
*
57+
* @return boolean
58+
*/
59+
public function dropOldCronLogs()
60+
{
61+
$statement = $this->getDb()->query('DELETE FROM cron_log WHERE created_at < DATE_SUB(NOW(), INTERVAL 12 HOUR)');
62+
$statement->execute();
63+
}
5364
}

0 commit comments

Comments
 (0)