Create CRON Script In Magento Module


Setting CRON in magento is easy

(Optional step) Firstly, install AOEscheduller

This will help you to see whether your configured CRON works or not.

Add this code to your Magento module etc directory config.xml.

                <schedule><cron_expr>0 1 * * *</cron_expr></schedule>

In next step create observer.php in Model’s directory.

class Inchoo_Birthday_Model_Observer
    public function sendBirthayEmail()
        //this collection get all users which have birthday on today
     	$customer = Mage::getModel("customer/customer")->getCollection();
    	$customer->addFieldToFilter('dob', array('like' => '%'.date("m").'-'.date("d").' 00:00:00'));
    	$items = $customer->getItems();
    	foreach($items as $item)
        // send email or do something		
        return $this;


Do not forget that you need set CRON for cron.php which takes care of reindexing, etc.


credit: Inchoo

Lukas Stranovsky
I am the guy who made this. Sorry for typos.