1

I have created cron in magento 2 but it run by command not run automatically run at every 5 minutes.

file: crontab.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="test">
        <job name="test" instance="Test\Ship\Cron\Observer" method="cronOderSync">
            <schedule>*/5 * * * *</schedule>
        </job>
    </group>
</config>

Cron set on system

*/5 * * * * php /home/var/www/html/magento/bin/magento cron:run | grep -v "R$
*/5 * * * * php /home/var/www/html/magento/update/cron.php >> var/www/html/m$
*/5 * * * * php /home/var/www/html/magento/bin/magento setup:cron:run >> var$

If I execute command on terminal then cron is working

 sudo php bin/magento cron:run --group="test"
1

I have solved it by adding some code in system cron file insteed of php I need to add /usr/bin/php which I get by

which php

command

*/5 * * * * /usr/bin/php  /var/www/html/magento-td/bin/magento cron:run | grep -v "Ran jobs by schedule" >> var/www/html/magento-td/var/log/magento.cron.log
*/5 * * * * /usr/bin/php  /var/www/html/magento-td/update/cron.php >> var/www/html/magento-td/var/log/update.cron.log
*/5 * * * * /usr/bin/php /var/www/html/magento-td/bin/magento setup:cron:run >> var/www/html/magento-td/var/log/setup.cron.log

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.