This is the first time I want to run cron for indexation every hour. I found multiple tutorials but none of them give me what I'm looking for or skip some steps.
I'm using OVH
as a web hosting, Magento 2.3.
Help, please.
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 communityThis is the first time I want to run cron for indexation every hour. I found multiple tutorials but none of them give me what I'm looking for or skip some steps.
I'm using OVH
as a web hosting, Magento 2.3.
Help, please.
use this cron expression
<crontab>
<jobs>
<stockalert_autosend>
<schedule><cron_expr>0 * * * *</cron_expr></schedule>
<run><model>stockalert/observer::backinstock</model></run>
</stockalert_autosend>
</jobs>
</crontab>
Please refer to the below documentation of OVh Web hosting to set automated tasks.
https://docs.ovh.com/gb/en/hosting/hosting_automated_taskscron/#create-an-automated-task
Example: Add the below code in your file you have set for schedule task:
//Assuming your file is in the Magento root folder.
<?php system('<path to php> <path to root>/bin/magento indexer:reindex') ?>
OR
<?php
$command = 'php /path-to-magento-root-directory/bin/magento indexer:reindex';
echo '<pre>' . shell_exec($command) . '</pre>';
?>
Also, check the below post if it is helpful!
https://stackoverflow.com/questions/44494242/ovh-cron-jobs-symfony-command
More, take a look at Magento documentation to Configure and run cron
https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-cron.html
Hope this helps!
whereis php
in terminal and it will show the path.
Aug 4, 2020 at 10:06
add new cron in your crontab
0 */1 * * * /usr/bin/php /YourMagentoInstallation/bin/magento indexer:reindex