1

This question already has an answer here:

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>

marked as duplicate by Muhammad Hasham, Shoaib Munir, Manashvi Birla, Jai, Teja Bhagavan Kollepara Jul 31 at 8:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • are you on local host ? – Pawan Feb 26 at 4:15
  • No, I am on live server – Surjan Raghuwanshi Feb 26 at 9:48
  • cron is working i.e send email and newsletter ? – Pawan Feb 26 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 at 17:02
  • if you set cron, your module cron will work automatically – Pawan Feb 26 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

  • is magerun2 custom extension – Surjan Raghuwanshi Feb 25 at 23:11
  • The answer has been updated with more information – Mr. Lewis Feb 25 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 at 23:22

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