1

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.

  • Please add more information to your question related to your requirement so one can help you here! – Bhaumik Upadhyay Jul 29 at 7:49
1

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>
| improve this answer | |
1
+50

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!

| improve this answer | |
  • I alrady saw this, but my issue is what should I put on the the file added on ovh! – Nouari zineb Aug 4 at 9:00
  • @Nouarizineb I have added an example in my answer. Add the code in your file and check if it works! – Bhaumik Upadhyay Aug 4 at 9:54
  • do you have any idea of the ovh php path plz? – Nouari zineb Aug 4 at 10:02
  • @Nouarizineb run whereis php in terminal and it will show the path. – Bhaumik Upadhyay Aug 4 at 10:06
  • it gives me all of tha paths:php: /usr/local/bin/php.BETA /usr/local/bin/php /usr/local/bin/php.ORIG /usr/local/lib/php.ini-3 /usr/local/lib/php.ini-0 /usr/local/lib/php.ini /usr/local/lib/php /usr/local/lib/php.ini-2 /usr/local/lib/php.ini-1 /usr/local/php5.5 /usr/local/php5.6 /usr/local/php5.3 /usr/local/php7.0 /usr/local/php7.3 /usr/local/php7.1 /usr/local/php7.2 /usr/local/php5.4 /usr/local/php7.1/bin/php – Nouari zineb Aug 4 at 10:14
0

add new cron in your crontab

 0 */1 * * *  /usr/bin/php  /YourMagentoInstallation/bin/magento indexer:reindex
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.