AI Reports

Magento 2 troubleshooting › Indexing and cron

How do I check if Magento cron is running?

Short answer: Look at cron_schedule: if nothing has executed in the last 15 minutes, cron isn't running. If it is, look for jobs with status error, missed, or running for hours.

Magento's cron runs every minute from the server's crontab (bin/magento cron:run). Each run schedules jobs in cron_schedule and records the result. Indexing, order emails, sitemaps, currency rates and clean-ups all depend on it.

Check it step by step

These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.

1. Did anything run in the last 15 minutes?

Works on Magento Open Source and Adobe Commerce:

SELECT MAX(executed_at) AS last_executed, MAX(finished_at) AS last_finished,
       SUM(status = 'pending') AS pending_jobs
FROM cron_schedule;

If last_executed is old, the crontab entry is missing or failing.

2. Errors in the last 24 hours

Works on Magento Open Source and Adobe Commerce:

SELECT job_code, COUNT(*) AS errors, MAX(executed_at) AS last_error, MAX(messages) AS example_message
FROM cron_schedule
WHERE status = 'error'
  AND executed_at >= NOW() - INTERVAL 1 DAY
GROUP BY job_code
ORDER BY errors DESC;

3. Jobs stuck in “running”

Works on Magento Open Source and Adobe Commerce:

SELECT job_code, executed_at, TIMESTAMPDIFF(MINUTE, executed_at, NOW()) AS minutes_running
FROM cron_schedule
WHERE status = 'running'
  AND executed_at < NOW() - INTERVAL 1 HOUR
ORDER BY executed_at;

4. Last successful run of each job

Works on Magento Open Source and Adobe Commerce:

SELECT job_code, MAX(finished_at) AS last_success
FROM cron_schedule
WHERE status = 'success'
GROUP BY job_code
ORDER BY last_success;

Jobs at the top of this list haven't succeeded for the longest time.

How to fix it

Good to know

Related

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn