When you have large number of products in your magento websites then doing indexing using magento admin panel sometimes may work and sometimes not. It may be due several reasons. In that case, command line indexing is a good option. you can just run the indexing in backgroud in a terminal window and your indexing will be done.
You can also automate the magento indexing by setup a cron at specific time so that you don’t need to trigger magento indexing manually.
Lets check below how to do command line magento indexing.
You should replace [MAGENTO_ROOT] with your own absolute path to Magento root folder. For example /var/www/public_html/magento1/
$ cd /var/www/html/magento1/shell
$ ls -l
Output something like the below screenshot :-
For checking status of magento indexing please execute below command
$ php indexer.php --status
Output something like the below screenshot :-
$ php indexer.php --reindex catalog_product_flat
Output something like the below screenshot :-
For Example, if you need to run magento indexing for Category Products Indexing, then you have to execute below command.
$ php indexer.php --reindex catalog_category_product
$ php indexer.php --reindexall
Sometimes you may want to run magento indexing as a background process so you can close the terminal and do other activity, therefore you don’t have to wait till magento indexing completion. In this scenario, you can use a command line tool, called nohup. This command allows you to run any CLI command in background independently from your current session. If you want to reindex something in background, then you need to follow the next step below.
$ nohup php indexer.php --reindex catalog_product_flat &
Output something like the below screenshot :-
$ nohup php indexer.php --reindexall &
After executing nohup command, you can safely log out of ssh session. You can also login back to the terminal or machine any time to look if the process was finished or not. for that you need to go to the shell directory again.
When you run magento indexing using nohup command in background then you see a nohup.out file has been created on the same directory. for checking the file in directory, execute below command.
$ cd /var/www/html/magento1/shell
$ ls -l
Output something like the below screenshot :-
For checking output of nohup.out file execute below command
$ cd /var/www/html/magento1/shell
$ cat nohup.out
Output something like the below screenshot :-
If you see an empty line or nothing, then you should allow some more time for the process to finish. Once indexing completed successfully then should see output on your screen as “Product Flat Data index was rebuilt successfully”.
if magento indexing was rebuild successfully then remove the file using below command.
$ rm nohup.out
Output something like the below screenshot :-
All Rights Reserved. ReadAndCare