Magento 2: How to set cron for reindex in SSH in magento 2?

All we need is an easy explanation of the problem, so here it is.

I want to know how to set cron for reindexing a particular indexer method in Magento 2. I have used below code to reindex all but not working:

* * * * * php –f /shell/indexer.php reindexall

Can somebody help?

my cronjob

enter image description here

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

You can launch reindex a separate index as independent process, like:

* * * * * /usr/bin/php /Users/uchuhlebov/web/m212/www/bin/magento indexer:reindex catalog_category_product >> /Users/uchuhlebov/web/m212/www/var/log/indexer.cron.log


  1. * * * * * – time
  2. /usr/bin/php – path to the php
  3. /Users/uchuhlebov/web/m212/www/bin/magento – path to your Magento CLI (/Users/uchuhlebov/web/m212/www/ – is Magento root dir)
  4. indexer:reindex catalog_category_product command you want to launch
  5. >> /Users/uchuhlebov/web/m212/www/var/log/indexer.cron.log – log output

In my example I launch reindex of the catalog_category_product index, but you can use any type. If you want to launch more than 1 reindex, you can specify them ( index name ) through the space.

Here you can find an answer for the question “How to get path of the php binary on server”:

It’s usually /usr/bin/php but you could try to capture and parse the
output of the command ‘whereis php’ or ‘which php”.

Or better yet, use the constant PHP_BINARY if it is available. Have a look here.

In addition check that your cron process is running: /etc/init.d/crond status should display something similar to crond (pid 1494) is running...

To view the list of available indexes use the command:

bin/magento indexer:info


design_config_grid                       Design Config Grid
customer_grid                            Customer Grid
catalog_category_product                 Category Products
catalog_product_category                 Product Categories
catalog_product_price                    Product Price
catalog_product_attribute                Product EAV
catalogsearch_fulltext                   Catalog Search
cataloginventory_stock                   Stock
catalogrule_rule                         Catalog Rule Product
catalogrule_product                      Catalog Product Rule

Method 2

* * * * * /usr/bin/php /path/to/your/site/root/bin/magento index:reindex <index_type>

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply