0

I have two models. The one is intializing the database, the other one i use to run a crontab. But i keep getting this error. Been playing around with it for a long time..

2017-11-29T08:56:03+00:00 ERR (3): Warning: include(Mage/Mycompany/Asynccronjobs/Model/Cron.php): failed to open stream: No such file or directory  in /var/www/mycompany/lib/Varien/Autoload.php on line 94
2017-11-29T08:56:03+00:00 ERR (3): Warning: include(): Failed opening 'Mage/Mycompany/Asynccronjobs/Model/Cron.php' for inclusion (include_path='/var/www/mycompany/app/code/local:/var/www/mycompany/app/code/community:/var/www/mycompany/app/code/core:/var/www/mycompany/lib:.:/usr/share/pear:/usr/share/php')  in /var/www/mycompany/lib/Varien/Autoload.php on line 94

My config.xml looks like this:

<?xml version="1.0"?>
<config>
    <modules>
        <Mycompany_AsyncCronjobs>
            <version>1.0.0</version>
        </Mycompany_AsyncCronjobs>
    </modules>
    <global>
        <models>
            <asynccronjobs>
                <class>Mycompany_AsyncCronjobs_Model</class>
                <resourceModel>asynccronjobs_resource</resourceModel>
            </asynccronjobs>
            <asynccronjobs_resource>
                <class>Mycompany_AsyncCronjobs_Model_Resource</class>
                <entities>
                    <jobs>
                        <table>asynccronjobs_jobs</table>
                    </jobs>
                </entities>
            </asynccronjobs_resource>
        </models>
        <helpers>
            <asynccronjobs>
                <class>Mycompany_AsyncCronjobs_Helper</class>
            </asynccronjobs>
        </helpers>
        <resources>
            <asynccronjobs_setup>
                <setup>
                    <module>Mycompany_AsyncCronjobs</module>
                </setup>
            </asynccronjobs_setup>
        </resources>
    </global>
    <frontend>
        <routers>
            <asynccronjobs>
                <use>standard</use>
                <args>
                    <module>Mycompany_AsyncCronjobs</module>
                    <frontName>asynccronjobs</frontName>
                </args>
            </asynccronjobs>
        </routers>
    </frontend>
    <crontab>
        <jobs>
            <Mycompany_AsyncCronjobs>
                <schedule>
                    <cron_expr>* * * * *</cron_expr>
                </schedule>
                <run>
                    <model>asynccronjobs_resource/cron::everyHour</model>
                </run>
            </Mycompany_AsyncCronjobs>
        </jobs>
    </crontab>
</config>

My Mycompany/AsyncCronjobs/Cron.php looks like this:

<?php
class Mycompany_AsyncCronjobs_Model_Cron extends Mage_Core_Model_Abstract
{

    public function everyHour()
    {
        mage::log('got it');
    }
}

1 Answer 1

1
<crontab>
    <jobs>
        <Mycompany_AsyncCronjobs>
            <schedule>
                <cron_expr>* * * * *</cron_expr>
            </schedule>
            <run>
                <model>asynccronjobs_resource/observer::everyHour</model>
            </run>
        </Mycompany_AsyncCronjobs>
    </jobs>
</crontab>

Edit:

I renamed Run to Observer.

You model should be in this path: Mycompany/AsyncCronjobs/Model/Observer.php and not : My Mycompany/AsyncCronjobs/Cron.php

<?php
class Mycompany_AsyncCronjobs_Model_Observer
{
    public function everyHour()
    {
        mage::log('got it');
    }
}
5
  • OK so i updated my post to your changes. I dont get the mage::log and i know my log is activated (can log from anywhere else), so somehow its not hitting it. I think somethings still missing
    – RappY
    Commented Nov 29, 2017 at 9:22
  • Have you the same error ?
    – PЯINCƎ
    Commented Nov 29, 2017 at 9:25
  • No i dont get an error anymore. And i can see its trying to run something here: 2017-11-29T09:27:03+00:00 DEBUG (7): Start: asynccronjobs_cron
    – RappY
    Commented Nov 29, 2017 at 9:28
  • Look my update please
    – PЯINCƎ
    Commented Nov 29, 2017 at 9:33
  • Ok somehow that works.. i really dont understand why, but thanks alot!
    – RappY
    Commented Nov 29, 2017 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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