How to directly RUN a function inside a controller class via cron?

In magento i tried to setup cron as following.

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

Here it calls model but how can i directly call a function inside the controller. For example

class Mage_Adminhtml_Inchoo_BirthdayController extends Mage_Adminhtml_Controller_Action

    public function sendAction($strFname)
        // this has to be called from cron in magento.


How i can directly call the sendAction action function inside the above controller from cron. In other words how this sendAction initiated from cron directly. I have to run the conroller function directly instead of model.

Please help me

2 thoughts on “How to directly RUN a function inside a controller class via cron?”

  1. you should treat this class as ordinary model.

    $observer = Mage::getModel('birthday/observer');

    Hope this is what You need.


    $curl = new Varien_Http_Adapter_Curl();
    $curl->setConfig(array('timeout'   => 20));
    $curl->write(Zend_Http_Client::GET, '');
    $curl->read(); //or without this line

    This should do the trick, if You want more info, please see content of Varien_Http_Adapter_Curl class.

    If You will only invoke one time sendAction inside cron model, then it’s ok…

    But i suggest to use cron itself, because it is more efficient rather than using Curl multiple times.

  2. You are doing it wrong 🙂 if you need to call a controller with all dispatchers and events you should use wget or curl to call your action. If you don’t need all events and dispatchers to fire then your method is just in wrong place

Leave a Reply

Your email address will not be published. Required fields are marked *