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.'));
}
} }