2

I have a couple cron jobs in my module

The problem is that the Magento cron doesn't run one of them, but runs the another one. I have already installed AoeScheduler and that allows to me to run these jobs manually. When I do that both of them run well.

So the only problem is when it runs through cron.php or cron sh. Also I can see that there's no new row on cron_shedule tab about this job.

This is my cron configuration y config.xml

        <validoc_bulksync_import_exigoprofile>
            <run><model>validoc_exigobulksync/cron::processImportProfile</model></run>
        </validoc_bulksync_import_exigoprofile>
        <validoc_bulksync_import_exigoitem>
            <run><model>validoc_exigobulksync/cron::processImportJobs</model></run>
        </validoc_bulksync_import_exigoitem>
    </jobs>
</crontab>

Im using a model class to suply the needed configuration for those jobs, just like i'd working with cron_path.

Validoc_Exigobulksync_Model_Adminhtml_System_Config_Backend_Exigobulksync_Cron extends Mage_Core_Model_Config_Data { const CRON_STRING_PATH = 'crontab/jobs/validoc_bulksync_import_exigoprofile>/schedule/cron_expr';

const CRON_STRING_PATH2 = 'crontab/jobs/validoc_bulksync_import_exigoitem/schedule/cron_expr';

protected function _afterSave() { $minute1 = $this->getData('groups/sheduleprofile/fields/minute/value'); $hour1 = $this->getData('groups/sheduleprofile/fields/hour/value'); $minute2 = $this->getData('groups/sheduleimport/fields/minute/value'); $hour2 = $this->getData('groups/sheduleimport/fields/hour/value');

$frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY; $frequencyWeekly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY; $frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;

$cronDayOfWeek = date('N');

$cronExprArray = array( $minute1, # Minute $hour1, # Hour (frequency == $frequencyMonthly) ? '1' : '', # Day of the Month '', # Month of the Year (frequency == $frequencyWeekly) ? '1' : '', # Day of the Week ); $cronExprArray2 = array( $minute2, # Minute $hour2, # Hour (frequency == $frequencyMonthly) ? '1' : '', # Day of the Month '', # Month of the Year (frequency == $frequencyWeekly) ? '1' : '', # Day of the Week );

$cronExprString = join(' ', $cronExprArray); $cronExprString2 = join(' ', $cronExprArray2); try { Mage::getModel('core/config_data') ->load(self::CRON_STRING_PATH, 'path') ->setValue($cronExprString) ->setPath(self::CRON_STRING_PATH) ->save(); } catch (Exception $e) { throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));

} try { Mage::getModel('core/config_data') ->load(self::CRON_STRING_PATH2, 'path') ->setValue($cronExprString2) ->setPath(self::CRON_STRING_PATH2) ->save(); } catch (Exception $e) { throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));

}

} }

  • Can you show us the cron configuration in the config.xml for both? – Smartie Sep 4 '15 at 18:10
  • i've edited my post, that's my configuration. the first one, is the one that doesn't work, both of them are configured in same way. – David Alvir Sep 4 '15 at 18:17
  • note: i have run this cron jobs y another thre sites and in all of then those work perfectly – David Alvir Sep 4 '15 at 18:21
  • Without a cron_expr or config_path node in your declaration, neither of these jobs can be run automatically as the Magento system does not know when to run them. – Smartie Sep 5 '15 at 8:03
  • I've edited my post, sorry, this is my first time using this question system, there is the reason why i didn't use the cron_expr, and i said before, this same script, is working in another thre enviroments. – David Alvir Sep 7 '15 at 14:48
2

Although you defined the model to run you didn't specify a schedule per task.

 <jobs>
        <validoc_bulksync_import_exigoprofile>
            <schedule><cron_expr>0 1 * * *</cron_expr></schedule>
            <run><model>validoc_exigobulksync/cron::processImportProfile</model></run>
        </validoc_bulksync_import_exigoprofile>
        <validoc_bulksync_import_exigoitem>
            <schedule><cron_expr>0 1 * * *</cron_expr></schedule>
            <run><model>validoc_exigobulksync/cron::processImportJobs</model></run>
        </validoc_bulksync_import_exigoitem>
    </jobs>

The schedule consists of several moment indicators

* * * * * 
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

Also make sure your server is running a Linux cronjob for cron.php

*/5 * * * * /usr/bin/php /path/to/magento/cron.php

And check the Apache and Magento logging for any possible errors. If one cronjob fails all that come after that will fail too.

  • Thanks for answer, maybe a did'n explain well, but i have the cron tab runing in magento, and it's runing all jobs, except, the first one of these jobs y my module, i didn't use the kind of configuracion of cron cus im usin system store values. – David Alvir Sep 4 '15 at 19:09
  • And when you run the task trough Aoe_Scheduler it does work? Do you run it directly or do you schedule it? Did you try and contact the module developer? – Sander Mangel Sep 4 '15 at 19:12
  • Yes, when i run the task trough Aoe_Sheduler it runs awsome, the worst is that i have another thre enviroments, stage, dev and my own local, and in these ones, all goes perfectly. – David Alvir Sep 4 '15 at 19:22
  • Sounds like it gives an error somewhere or fails in some condition. Thats the only reason I can think of, specially if it runs on other locations – Sander Mangel Sep 4 '15 at 19:24
  • well, im really confused, because is the same code in all locations, im using the same repository for all of them. – David Alvir Sep 4 '15 at 19:26

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.