How to Run cron job manually via Command Line in Magento 2

Magento has a way to make all of your future plans! First, let’s talk about the cron job. This type of task is used by many Magento features. A partial list of these are: catalog price rules, generating Google sitemaps, customer alerts/notifications for changes in product prices, product stock, reindexing, and private sales. If you use Adobe Commerce, it works for private sales. Magento also has something called automatic currency rate updates and all confirmation emails and emails for transactions too.

In this tutorial, we will talk about How to Run cron job manually via Command Line in Command Line Series. As you know, from Magento 2, they add many commands in bin/magento. This may be difficult to approach, so let me explain in more detail about How to Run cron job manually via Command Line.

Find out How to Create Cron Jobs programmatically

What is Cron Job?

In Magento 2, a cron job also operates as a scheduled task such as sending emails, indexing products, and generating reports,…Think of it as an automated assistant taking care of essential behind-the-scenes tasks while you focus on running your business.

Here are the main benefits of Cron Job:

  • Maintain performance: Regular tasks like flushing cache, reindexing product information, and optimizing search engines keep your store delivering quick responses to customers.

  • Update data: Product feeds, order processing, and inventory synchronization rely on cron jobs to stay accurate and current.

  • Security and system checks: Automated scans for vulnerabilities, database backups, and security patches ensure your store remains protected.

  • Custom tasks: Developers can utilize Magento’s cron framework to automate their custom scripts and functionalities specific to your store’s needs.

Cron jobs are essential for keeping your Magento 2 store running smoothly and securely. Utilize them effectively to free up your time, optimize performance, and focus on delivering the best possible experience for your customers.


Cron Schedule

Cron Schedule for Magento 2

A great tool to help store admins view, manage, and schedule cron tasks with ease from the store backend (Hyva ready)

Check it out!


How to Run cron job manually via Command Line

Go to Magento admin root folder and show usage:

php bin/magento cron:run --help
Usage:
  cron:run [options]

Options:
      --group=GROUP          Run jobs only from specified group
      --bootstrap=BOOTSTRAP  Add or override parameters of the bootstrap
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Runs jobs by schedule

Syntax to Run Cron Manually

php bin/magento cron:run [options]

Let run cron job manually command line. Type in the command line in root folder of Magento 2:

php bin/magento cron:run

Output:

Ran jobs by schedule.

You may get this error:


  [Exception]
  Warning: file_put_contents(./var/cache//mage-tags/mage---6b9_TRANSLATE): failed to open stream:
  Permission denied in ./vendor/colinmollenhour/cache-backend-file/File.php on line 663


cron:run [--group GROUP] [--bootstrap BOOTSTRAP]

You should make sure the var folder is writable.

Run Cron job with options

  • --group=GROUP : Run jobs only from specified group
  • --bootstrap=BOOTSTRAP : Add or override parameters of the bootstrap

All done! Using the Command Line to run cron jobs manually is not difficult at all, right? I hope you could do it right away after one try, but if not, don’t worry, contact us here or comment below for further support.

Explore Mageplaza Cron Schedule extension

Image Description
Hello, I'm the Chief Technology Officer of Mageplaza, and I am thrilled to share my story with you. My deep love and passion for technology have fueled my journey as a professional coder and an ultra-marathon runner. Over the past decade, I have accumulated extensive experience and honed my expertise in PHP development.

People also searched for

  • magento 2 run cron job manually
  • magento 2 run specific cron job manually
  • magento run cron job manually
  • magento2 run cron job manually
  • magento 2 cron run command
  • magento 2 run cron manually
  • run cron manually magento 2
  • run cron magento 2
  • run cron job magento 2 command
  • magento 2 run cron
  • magento 2 manually run cron
  • cron run magento 2
  • magento 2 run cron command line
  • how to run cron job manually in magento 2
  • php bin/magento cron:run
  • magento 2 cron run manually
  • cron run command in magento 2
  • magento 2 run cron from command line
  • run cron job magento 2
  • magento 2 cron run
  • magento cron run
  • how to run cron job manually
  • magento cron:run
  • magento 2 debug cron job
  • magento 2 run cron job
  • 2.3.x, 2.4.x
x