How To Configure Cron Jobs In Magento 2

A Miniature Shopping Cart on MacBook Laptop

Cron jobs are an essential feature in any web application. They enable you to schedule tasks that need to be performed automatically at specific intervals. In Magento 2, cron jobs are used for various things, such as indexing products, generating sitemaps, sending newsletters, and updating currency rates. In this article, we will explore how to configure cron jobs in Magento 2.

Speed Up Your Magento Store by 300%

Understanding Cron Jobs

Before we dive into the configuration process, it’s essential to understand the basics of cron jobs. Cron is a time-based job scheduler in Unix-like operating systems. It runs in the background and executes commands or scripts at specific time intervals.

Cron jobs in Magento 2 are managed by the Magento cron scheduler. The scheduler is responsible for triggering tasks at pre-defined intervals and ensuring that they are executed successfully.

Enabling Cron Jobs in Magento 2

Before you can configure cron jobs in Magento 2, you need to enable the scheduler. To do so, follow these steps:

  1. Log in to the Magento 2 admin panel.
  2. Go to Stores > Configuration > Advanced > System > Cron (Scheduled Tasks).
  3. Set Enable to Yes.

Once you have enabled the cron scheduler, you can configure the cron jobs.

Configuring Cron Jobs in Magento 2

Magento 2 comes with predefined cron jobs that are preconfigured to run at specific intervals. These cron jobs are essential for the proper functioning of your store. However, you might need to add custom cron jobs that are specific to your requirements.

To configure cron jobs in Magento 2, follow these steps:

  1. Log in to the Magento 2 server using SSH.
  2. Navigate to the Magento 2 root directory.
  3. Run the following command to enter the crontab editor:
crontab -e
  1. In the crontab editor, add the following lines of code:
* * * * * php /path/to/magento2/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /path/to/magento2/var/log/magento.cron.log
* * * * * php /path/to/magento2/update/cron.php >> /path/to/magento2/var/log/update.cron.log
* * * * * php /path/to/magento2/bin/magento setup:cron:run >> /path/to/magento2/var/log/setup.cron.log

The first line of code is responsible for running the Magento cron jobs. It will trigger all scheduled tasks at the specified intervals.

The second line of code runs the Magento updater. It checks for new updates and installs them automatically. This is an optional step, and you can remove this line if you don’t need it.

The third line of code runs the Magento setup cron tasks. These tasks include reindexing, sending emails, generating sitemaps, and more.

Verifying Cron Jobs

Once you have configured the cron jobs, you need to verify that they are running correctly. To do so, follow these steps:

  1. Log in to the Magento 2 admin panel.
  2. Go to System > Cron Scheduler.
  3. You should see a list of all scheduled tasks and their status.
  4. Check that the tasks are running at the specified intervals and that there are no errors.

You can also check the cron logs in the var/log directory to see if there are any issues with the tasks.


Configuring cron jobs in Magento 2 is a critical task that ensures the smooth functioning of your store. By following the steps mentioned in this article, you can configure cron jobs correctly and ensure that your tasks are running consistently. Remember to monitor the scheduler and logs regularly to detect and fix any issues.

Scroll to Top