Please provide me a solution with a code.
If you're using ubuntu you can open configured cron jobs by using command crontab -e
.
Now let's say you want to run indexer every minute, you can configure it like this
# m h dom mon dow command
*/01 * * * * /usr/bin/php /var/www/html/magento2/bin/magento indexer:reindex
-
This is not the solution. Why would you reindex everything every minute, negating the benefits of the indexes? See Akhilesh comment with link to Magento docs on how to set it up. – Adam Lavery Aug 2 '18 at 8:14
-
This was just an example as mentioned in the answer. Of course you have to keep it's impact in mind and set time accordingly. – amitshree Aug 2 '18 at 9:56
There is a whole section in the magento develop docs which discuss how to go about setting up the cron and the different scenarios
https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-cron.html
The only difference is that you would use php bin/magento index:reindex
If you are still stuck you could reach out to your host. If you get someone good they might help you out with what do do that's specific to who you are using.