Magento – set up cron using config.xml

cron

Hi i am tring to set up cron in magento using config.xml. but anyreason its not working,
Here is the code which i am using.

config.xml

<?xml version="1.0"?>
<config>
    <global>
        <models>
            <mycompany_mymodule>
                <class>Mycompany_Mymodule_Model</class>
            </mycompany_mymodule>                         
        </models>
    </global>
    <crontab>
        <jobs>
            <mycompany_mymodule>
                <schedule><cron_expr>*/10 * * * *</cron_expr></schedule>
                <run><model>mycompany_mymodule/observer::importproduct</model></run>
            </mycompany_mymodule>
        </jobs>
    </crontab>
</config>

Observer.php

<?php  
class Mycompany_Mymodule_Model_Observer {  
    public function Importproduct() {
        Mage::log('cron works!!',null,'cron.log');
    }  
}  ?>

but its not working, can anybody help me.
Thank you in advance..

Best Answer

An answer with a collection of all the comments:

Is your cron actually setup? is cron.php being called by your system's cron? Try running cron.php yourself.

Is your module enabled in app/etc/modules/? In other words, did you check whether the module itself is loaded at all?

Also, in your config.xml you reference this: mycompany_mymodule/observer::importproduct where you call the function importproduct and in your PHP code it's Importproduct, note the capital I.

Related Topic