Magento cron job is a job scheduler used for generating sitemaps, notifying customer alerts, indexing and caching, etc.
You can use Magento cron jobs to automate all mundane tasks that improve store operations as a store admin. This tutorial shows you how to run a cron job manually via the command line.
This guide assumes you’ve already configured and created a Cron. We’ll be covering how to run a cron job manually in Magento 2.
How to Run a Cron job Manually in Magento 2
The syntax to run cron manually is as follows:
php bin/magento cron:run [options]
Log in to your Magento server as the file system owner and head to the Magento installation directory.
Run the following command to run all the cron jobs:
php bin/magento cron:run
You should see the following output:
Ran jobs by schedule
You may get the following error if you don’t have permission to the “/var/cache” folder:
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]
Make the “var” folder writable using the “chmod” command and rerun the above command.
To run a specific cron group, run the following command:
bin/magento cron:run [--group=<cron group name>]
For example, use the following command to run the default cron job:
bin/magento cron:run --group default
Enter this command to run the indexing cron job:
bin/magento cron:run --group index