Magento logs every cron job it schedules and runs in the cron_schedule table. It is supposed to prune old rows automatically. On many stores it does not, and the table grows to hundreds of thousands or millions of rows.
Why it matters
Magento reads this table every minute when cron runs. A huge table makes every cron run slower, which gradually delays everything cron is responsible for: order emails, indexing and scheduled tasks. In bad cases, cron runs overlap and pile up.
Check the size
SELECT status, COUNT(*) FROM cron_schedule GROUP BY status;
A healthy store usually has a few thousand rows at most.
How to clean it
Delete finished history in batches, so the table is never locked for long:
DELETE FROM cron_schedule
WHERE status IN ('success', 'missed', 'error')
AND scheduled_at < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY)
LIMIT 10000;
Repeat until it reports 0 rows affected. Do not delete pending or running rows. Those are jobs that are scheduled or in progress.
Deleting rows does not give the disk space back on its own. To reclaim it, rebuild the table during a quiet time (see reclaiming space with OPTIMIZE TABLE).
Stop it growing again
Magento’s own cleanup only removes rows older than the history lifetimes set for each cron group. Check them under Stores > Configuration > Advanced > System > Cron (Scheduled Tasks):
- History Cleanup Every: 10 minutes is the default.
- Success History Lifetime: 60 minutes is the default.
- Failure History Lifetime: 4320 minutes (3 days) is the default.
If someone set these to weeks, the table will keep growing. Also make sure cron itself runs. Cleanup is part of cron, so a broken cron means no cleanup.
Catch it automatically
MageMonitor checks for this every few minutes as part of its Cron Health checks, and alerts you by email, Slack or webhook the moment it appears, with the exact commands to fix it. See MageMonitor for Magento 2.
