3

I'm trying to set-up a cron job for multiple models. I have two methods (method1 and method2) in Model (observer.php) for which I want to set cron job. My code :

Config.xml file :

 <crontab>
        <jobs>            
        <erpbridge_update>
            <schedule>
                <cron_expr>* * * * *</cron_expr>
            </schedule>
            <run>
                <model>erpbridge/observer::method1</model>
            </run>

        </erpbridge_update>  
        <mss_erpbridge>
                <schedule>
                <cron_expr>* * * * *</cron_expr>
            </schedule>
                <run>
            <model>erpbridge/observer::method2</model>
            </run>
            </mss_erpbridge>

        </jobs>
    </crontab>

Name space is Mss and module name is Erpbridge, Cron job with the right module name working perfectly <mss_erpbridge> but this is not working </erpbridge_update>. When I set the same key for both <mss_erpbridge> then only the second works.

My query :

Is it possible to set a cron job for multiple Models if yes, How?

  • Your syntax is correct, are you sure the problem is not elsewhere? – Phoenix128_RiccardoT Feb 26 '16 at 21:01
1

Deepak, may be at any xml file you have using erpbridge_update name cronjob.

I suggest to you use any another name for cronjob identofier event name.

As magento save the cronjob idenfier in cronjob table at db and basic of this table magento cronjob is excute. So, you cannot use name idenfier name for two cronjob.

For example from app/code/core/Mage/CatalogRule/etc/config.xml:

<config>
...
    <crontab>
        <jobs>
            <catalogrule_apply_all> <!-- this is  indentifier name which is save at db -->
                <schedule><cron_expr>0 1 * * *</cron_expr></schedule>
                <run><model>catalogrule/observer::dailyCatalogUpdate</model></run>
            </catalogrule_apply_all>
        </jobs>
...
    </crontab>
...
</config>
  • I tried using different name, but having same issue. – Deepak Mankotia Jun 4 '15 at 6:17
  • I have one query, can we use any unique key "<catalogrule_apply_all>" for this of just "<modulename/model>" name? – Deepak Mankotia Jun 4 '15 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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