How to Create a Cron Job for Rebuilding Product Index in Linux Server
Sometimes we may find that some newly added products are not available to be searched in the shop. The reason is that the product is still not included in the product index.
The situation is like you have bought some books, but haven’t put them onto the book self yet.
However, in PrestaShop, the products should be automatically indexed into the search when they are saved in the Backoffice. But if you are using some third-party software to manage the catalog (where they may directly communicate with the database) etc. The product index may not be complete.
We are going to discuss how to index the product on below.
Manually re-build
- Backoffice access (for manually re-build)
Scheduled re-build by cron job
- Server access / Web hosting account (for creating cron job)
- curl / wget command
You may find related settings in backoffice under [Shop Parameters] ⇒ [Search]. You should see a section like below picture:

The details are shown here, where you may know how many products are indexed. 2 choices are available in the middle, which allow you to choose whether re-build the whole index or only insert the missing products. Simply clicking on them will do the trick!
Cron is a build-in function in Linux system which allow users to schedule tasks. This can be done directly on the server or some hosting platforms like cPanel or Cloudways.
Cron use a row of 5 value to define the schedule time, below are some examples:
* * * * *
means to execute at every minute
0 3 * * *
means to execute at 3am each day
0 5/12 * * *
means to execute at 5am & 5pm each day
0 */3 * * *
means to execute every hours
0 0 1,15 * 3
means to execute at 00:00 if it is the 1st or 15th or the month and it is Wednesday
If you are not sure about your inputs, you may check and get a human-readable description here: crontab.guru


crontab -e


Tasks can be scheduled by inputting entry at the bottom with below format:
[Period] [Command]
For example:
0 3/12 * * * curl "https://xxx....."
There are 2 commands can do the trick:
wget "[URL]" -O /dev/null
wget
is usually pre-installed in Linux machine. However, running wget
command will save file on the current directory. Using the switch -O /dev/null
could prevent this happen
curl "[URL]"
curl
looks simply but it is not always pre-installed in Linux machine. Please make sure you have this command available before you create the cron job.
There is a BUG in version 1.7.6.0 & 1.7.6.1, where you are not able to re-build the index by using cron job. Please make sure your shop is having a version ≥ 1.7.6.2 to ensure the cron job works.
If you are unfortunately using 1.7.6.0 / 1.7.6.1, we recommend you to upgrade the version or use the fix provided below:
Related Post
How to backup database from the back office in Prestashop 1.7.x?
Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/genkiware/wp-content/themes/optima/single.php on line 185
The following steps will show you how to backup database…
Floating Social Media Icons Deployment on Prestashop (Free Campaign)
Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/genkiware/wp-content/themes/optima/single.php on line 185
This is a service dedicated for Prestashop community members. If…