5

I want to run the cron job on magento, but the cron events are not appeared. This is my etc/config.xml file.

<crontab>
    <jobs>
         <imagerecycle_imagerecycle>
            <schedule>
                <cron_expr>*/1 * * * *</cron_expr>
            </schedule>
            <run>
                <model>imagerecycle/observer::cronexec</model>
            </run>
         </imagerecycle_imagerecycle>
    </jobs>
</crontab>

And I define the cron event ovserver function.

class Imagerecycle_Imagerecycle_Model_Observer
{
    public function cronexec($observer)
    {
        // do something
    }
}

And to run the cron I use such a command line at the command prompt.

D:\work\magento>schtasks /create /sc minute /mo 1 /tn "my cron" /tr "php -f d:\work\magento\cron.php

So the cron.php is called every 1 minutes.
But my cronexec() function are not working. So I installed the AOE-Scheduler extension and reviewed the information. There was my cron function correctly. By the way there is a message "there is no heartbeat work now". I guess there is no error on my php program. Only the magento cron cannot run on the windows 7. Is is right? Please help me.

3 Answers 3

0

Cron Setup looks fine. You can also just run cron.php from browsers as

http://SITE_BASE_URL/cron.php

Resource Magento Basic Cron Job Module setup

2
  • Thank u. But there cron is not working. Do u have another method? If u want , I will send more info.
    – wuang li
    Mar 26, 2016 at 23:54
  • OK. I am trying to find the solution, so I have find the issue. That is magento core error. To run the cron, magento must generate the schedule internally. so I found the Mage_Cron_Model_Observer->generate(). [link] doc4dev.net/doc/Magento/1/class-Mage_Cron_Model_Observer.html So I reinstall the magento, there is nothing. Thank u everyone.
    – wuang li
    Mar 27, 2016 at 4:20
0

Need to declare Model in config.xml file.

<config>
    <global>
        <models>
            <imagerecycle>
                <class>Imagerecycle_Imagerecycle_Model</class>
            </imagerecycle>                         
        </models>
    </global>
    <crontab>
        <jobs>
            <imagerecycle>
                <schedule>
                    <cron_expr>*/10 * * * *</cron_expr>
                </schedule>
                <run>
                    <model>imagerecycle/observer::cronexec</model>
                </run>
            </imagerecycle>
        </jobs>
    </crontab>
</config>
0

To run cron,

1) check php is globle command or not if it is globle command you can use it as php else you have to specify full path of php.exe

2) you have to create one magento.sh file write command on there which you want (php -f d:\work\magento\cron.php).

3) now create Schedule Task for magento.sh you can create it by this link

Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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