Magento 1.9 – Cron Job Not Working Using Module

croncrontabmagento-1.9

I am new to Magento and trying to run Cron Job using module.

Here is my code
app/etc/modules/FQLabs_Automail.xml

<?xml version="1.0"?>
<config>
    <modules>
        <FQLabs_Automail>
            <active>true</active>
            <codePool>local</codePool>
        </FQLabs_Automail>
    </modules>
</config>

app/code/local/FQLabs_Automail/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
    <FQLabs_Automail>
        <version>0.1.0</version>    <!-- Version number of your module -->
    </FQLabs_Automail>
</modules>

<crontab>
    <jobs>
        <fqlabs_automail_send>
            <schedule>
                <cron_expr>*/5 * * * *</cron_expr>
            </schedule>
            <run>
                <model>automail/observer::doSomething</model>
            </run>
            </fqlabs_automail_send>
        </jobs>
    </crontab>

</config>

app/code/local/FQLabs_Automail/Models/observer.php

<?php 
class FQLabs_Automail_Model_Observer
{

    public function doSomething()
    {
        Mage::log("This is a cron run test", null, 'mylog.log');
        return $this;
    }


}

?>

After clearing cache and re indexing indexes, I hit (www.yourstore.com/cron.php)
I have done everything right but still the log is not working.
Please suggest some help.
Module Link for Debug is here

Best Answer

app/code/local/FQLabs_Automail/Models/observer.php

is wrong, should be

app/code/local/FQLabs/Automail/Model/Observer.php

Refresh your configuration cache and you should then confirm that your module cron task is enabled in Magento, you can look for this in the database but I recommend you install the AOE Scheduler module http://fbrnc.net/blog/2011/03/magento-cron-scheduler

This will give you a detailed graphical view of all magento cron tasks, you should also see your cron job there if your module is configured properly.

You can manually schedule the cron job to run with AOE Scheduler and check your system log file for the output. Running cron.php from your browser will not necessarily run the job, as you have scheduled it to run every 5 mins.

This should help you troubleshoot the problem further.

Related Topic