1

My custom CRON job not working automatically, but if I run it using command line then it is working.

I created basic module and below is my code for CRON job

crontab.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="default">
        <job name="cron_example" instance="companyname\modulename\Cron\Example" method="execute">
            <schedule>* * * * *</schedule>
        </job>
    </group>
</config>
7
  • are you on local host ? – Pawan Feb 26 '19 at 4:15
  • No, I am on live server – Surjan Raghuwanshi Feb 26 '19 at 9:48
  • cron is working i.e send email and newsletter ? – Pawan Feb 26 '19 at 16:36
  • are they trigger by cron, not sure need to check. my cron is working using command line, then why it is not working automatically, do i need to configure somewhere – Surjan Raghuwanshi Feb 26 '19 at 17:02
  • if you set cron, your module cron will work automatically – Pawan Feb 26 '19 at 17:04
0

When you have magerun2 installed you can run the following command:

magerun2 sys:cron:run

Now you get a list of available cronjobs and if your job is configured correctly it should be shown and then you can use the key number to trigger it.

More informatief about how to install or use magerun2 can be found here:

https://github.com/netz98/n98-magerun2

3
  • is magerun2 custom extension – Surjan Raghuwanshi Feb 25 '19 at 23:11
  • The answer has been updated with more information – Mr. Lewis Feb 25 '19 at 23:18
  • Thank you for explanation, but as I scheduled my job in Magento as <schedule>* * * * *</schedule> why it is not running automatically, it is working if I run it from command line – Surjan Raghuwanshi Feb 25 '19 at 23:22

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