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

To Run cron job manually via Command Line

To run the cron job manually, go to the Magento admin root folder.

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 the cron job manually command line.

php bin/magento cron:run

Output:

Ran jobs by schedule.

You may get an 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 a specified group
  • --bootstrap=BOOTSTRAP : Add or override parameters of the bootstrap

 

If you are looking for Magento 2 Developer, visit Magento Developer Agency.