Magento 2 How To Run Cron Job Manually Via Command Line

In this tutorial, we will see that How to Run Cron Job Manually Using Command Line. In Magento 2, there are multiple commands added and they can run by “php bin/magento commandName”

To Run cron job manually via Command Line, we need to do the following:

  1. 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

Following is the syntax to run a cron manually:

php bin/magento cron:run [options]

Now Lets run the cron job manually via command line.

Type the following in the command line in root folder of Magento 2 to run the cron:

php bin/magento cron:run

Output:

Ran jobs by schedule.

You may or may not 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]

If you get above error, you have to make sure the Magento root var folder has write permissions.

Run Cron job with options

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

Leave a Reply