Cronjob Setup for Magento 2 Guide

Magento 2 relies heavily on cron jobs for background tasks. Without properly configured cron, many features won't work - including email sending, indexing, feed generation, and most third-party extensions. This guide helps you set up and verify cron is running correctly.

Why Cron Matters

Cron handles critical background tasks:

  • Indexing - Keeps catalog, prices, and search data current
  • Email queue - Sends order confirmations, newsletters, notifications
  • Feed generation - Creates product feeds for Google Shopping, marketplaces
  • Order processing - Imports orders from channels like Channable, Bol.com
  • Cache management - Cleans expired cache entries
  • Log cleanup - Manages log file sizes
  • Scheduled imports/exports - Runs data transfers

If your Magento store has issues with any of these, cron misconfiguration is often the cause.

Quick Setup

1. Navigate to Magento Directory

cd /var/www/html/magento2

Replace with your actual Magento installation path.

2. Install Cron Jobs

Run as the web server user (often www-data, apache, or magento):

bin/magento cron:install

This automatically adds the required entries to crontab.

3. Verify Installation

Check that cron entries were added:

crontab -l

You should see entries like:

* * * * * /usr/bin/php /var/www/html/magento2/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/html/magento2/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/update/cron.php >> /var/www/html/magento2/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/bin/magento setup:cron:run >> /var/www/html/magento2/var/log/setup.cron.log

Manual Cron Test

Run cron manually to verify it works:

bin/magento cron:run

If successful, you'll see output about scheduled jobs being processed.

Check Cron Status in Admin

Go to System → Cron Schedule (if available) or check the cron_schedule database table:

SELECT * FROM cron_schedule ORDER BY scheduled_at DESC LIMIT 20;

Healthy cron shows jobs with status = 'success' and recent executed_at timestamps.

Troubleshooting

Cron Not Running

Check cron service is active:

# Debian/Ubuntu
systemctl status cron

# CentOS/RHEL
systemctl status crond

Check Magento cron log:

tail -100 var/log/magento.cron.log

Check system cron log:

# Debian/Ubuntu
tail -100 /var/log/syslog | grep CRON

# CentOS/RHEL
tail -100 /var/log/cron

Permission Issues

Ensure the web server user owns the crontab:

# Check current user's crontab
crontab -l

# If needed, install as specific user
sudo -u www-data bin/magento cron:install

PHP Path Issues

If cron jobs fail, the PHP path might be wrong. Find your PHP binary:

which php

Then manually edit crontab if needed:

crontab -e

Jobs Stuck in "pending" or "running"

Clear stuck jobs:

bin/magento cron:remove
bin/magento cron:install

Or directly in database:

DELETE FROM cron_schedule WHERE status = 'pending';
DELETE FROM cron_schedule WHERE status = 'running';

Memory Errors

If cron jobs fail with memory errors, increase PHP CLI memory in php.ini or create a wrapper script:

#!/bin/bash
/usr/bin/php -d memory_limit=2G /var/www/html/magento2/bin/magento cron:run

Multi-Environment Setup

For staging and production environments, ensure each has its own cron configuration. Don't share crontabs between environments - this causes conflicts and duplicate processing.

Removing Cron Jobs

To uninstall Magento cron entries:

bin/magento cron:remove

Need More Help?

Documentation:

Support:

Article Updated:
star star star star star
star star star star star
Alexandru-Manuel Carabus
Magmodules sets the bar for Magento module quality and support—we check their catalog first for client feature requests, and they’re our first choice for licenses.
Google 11 Nov 2025
star star star star star
star star star star star
Matt Austin
Possibly the fastest support response times of any Magento Extension vendor. Great extensions too!
Google 09 Sep 2025
star star star star star
star star star star star
Jan Privé
Dankzij de heldere uitleg en snelle reactie van Magmodules kon mijn vraag, en dus mijn Magento-probleem, binnen enkele uren worden beantwoord. Doeltreffend, zonder moeilijke termen, gewoon zo als het zou moeten zijn.... Bedankt!
Google 05 Sep 2025
star star star star star
star star star star star
Denis Metzler
To evaluate a provider, it is not enough to consider only the product offered, but also its after-sales service, such as support and troubleshooting. Magmodules has been extremely satisfactory at all levels on multiple occasions and sets the bar at the top when comparing the competition.
Google 02 Sep 2025
star star star star star
star star star star star
Bleijenberg winkelinrichting en materialen
Goed bereikbaar, reageren snel en denken oplossingsgericht. Een aanrader.
Google 30 Jul 2025
star star star star star
star star star star star
Patrick Verduijn
Magmodules biedt plugins aan die van hoge kwaliteit zijn tegen een goede prijs, waar dit bedrijf in uitblinkt is de bereidheid om de zeldzame feedback & problemen met de plugins te willen onderzoeken, mee te willen denken in het debuggen van problemen en goede oplossingen toe te passen. In mijn decennium ervaring met Magento & 3th parties is Magmodules absoluut een uniqum binnen de markt.
Google 25 Jul 2025
star star star star star
star star star star star
Erik de Groot
Magemodules heeft hele sterke Magento extensies en een proactieve support. Al jaren heel erg tevreden over jullie service en producten!
Google 18 Jul 2025
star star star star star
star star star star star
René Zeuner
We are using the Mollie Magento extension from Magmodules. It works excellently without flaws. Very fast, competent and friendly support. Thanks!
Google 30 Jun 2025
star star star star star
star star star star star
R. U.
Erg goed team, reageren snel en duidelijk en hebben met toegang tot onze database erg goed geholpen (eigenlijk een gratis customization).
Google 18 Jun 2025
star star star star star
star star star star star
Hugo de Groot
Uitstekende support! Wij gebruiken o.a. de Rich Snippets Suite extensie voor onze Magento 2 webshop (Hyvä) en hadden een specifieke vraag over structured data op PLP-pagina’s. Binnen no-time kregen we een inhoudelijk en duidelijk antwoord. Zeer prettig contact en goed onderbouwde uitleg. Absoluut een betrouwbare partner voor Magento-extensies!
Google 13 Jun 2025