Pre Black Friday Sale. 20% OFF on all products. Coupon code: fme20off

How to Run Magento 2 Cron Job Manually via Command Line?

How to Run Magento 2 Cron Job Manually via Command Line?

As the title indicates, this article talks about how to run cron job manually in Magento 2. Before we talk about the steps, let’s first gain a comprehensive understanding of this function.

What is a Cron Job?

Magento is amongst the most widely used eCommerce platforms worldwide. If you are still not using to manage your store, we recommend switching right away. It offers a wide range of features that truly make it a better choice. One of the most distinguishing features of Magento 2 is cron job.

A cron job is a scheduled task on your server to be run automatically at a specified time and date. They are extremely useful to automate repetitive tasks. Cron job offer you complete control over when to run an activity. They are easy to code and manage. Moreover, they do not occupy memory when they are not running.

By automating the repetitive tasks, you can focus on other value-addition tasks like customer management and strategy development. Indeed, with the ever-increasing competition, it is the value-addition activities that will help your store differentiate itself from the competitors.

Why is Magento Cron Job Important?

Besides automating the repetitive tasks, why is the cron job important? There are several reasons why you need to implement the run cron manually Magento 2 function:
  • It keeps the website data up-to-date by clearing the older data. This enhances your store’s performance.
  • By running updates automatically, your store has the latest security and performance features. It ensures a seamless experience for all users.
  • Automating tasks like order processing prevent the risk of human error or delay.
  • Cron job can be used to automate inventory management, thereby avoiding risk of stockouts and overstocking.

List of Activities That Can be Scheduled via Cron

The following is a partial list of activities that can be scheduled via cron. Many Magento features are based on these scheduled activities. Improper configuration of cron job will lead to Magento not functioning as expected.
  • Reindexing
  • Catalog price rules
  • Generating Google sitemaps
  • Newsletters
  • Private sales (Magento Commerce only)
  • Customer alerts and notifications
  • Automatic update of currency rates
  • Magento emails
Remember, in Magento 2, you can run cron job every minute, hour, day of the week, day of the month, month or any combination of these. In this guide, we are going to see how to run Magento 2 cron job manually from the command line.

How To Run Cron From The Command Line in Magento 2?

We recommend running cron as a user with permission to write to the Magento file system. Do not run cron as root or as the web server user. The following syntax is used to run cron from the command line. The following syntax is used to run cron from the command line.
 
bin/magento cron:run [--group="<cron group name>"]

In this way, you can run specific cron job manually.

where --group defines the cron group to run. Omit this option to run cron for all groups like the following.
 
bin/magento cron:run
To run the indexing cron job, enter:
 
bin/magento cron:run --group index
To run the default cron job, enter:
 
bin/magento cron:run --group default

You must run cron twice. The first time to discover tasks to run and the second time to run the tasks themselves.

Conclusion

This concludes our article on how to run cron job manually in Magento 2. If you need any help to setup Magento 2 cron scheduler, feel free to contact our support team.


FAQs

What is a cron job in Magento 2?

It is an automation function. Magento 2 store owners can use it to run tasks at set intervals without manual intervention.

What functions can I automate using cron job?

There are several functions that you can automate such as updating currency rates, newsletters, and system optimisation.

Is this function available on all versions of Magento?

Yes, this function is available on versions of Magento.

Conclusion

This concludes our article on how to run cron job manually in Magento 2. If you need any help to setup Magento 2 cron scheduler, feel free to contact our support team.

This blog was created with FME's SEO-friendly blog