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?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityYou 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
Where:
* * * * *
- time/usr/bin/php
- path to the php/Users/uchuhlebov/web/m212/www/bin/magento
- path to your Magento CLI (/Users/uchuhlebov/web/m212/www/
- is Magento root dir)indexer:reindex catalog_category_product
command you want to launch>> /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
Result:
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
/etc/init.d/crond status
should display something similar to crond (pid 1494) is running...
. Please, look at my updated answer.
Dec 8, 2016 at 10:58
/opt/bitnami/php/bin/php
in the cronjob
Dec 8, 2016 at 11:05
* * * * * /usr/bin/php /path/to/your/site/root/bin/magento index:reindex <index_type>
pub/cron.php