private function executeConfigModel($callback, $jobCode)
{
Mage::getConfig()->init()->loadEventObservers('crontab');
Mage::app()->addEventArea('crontab');
/* @var $schedule Mage_Cron_Model_Schedule */
$schedule = Mage::getModel('cron/schedule');
if (false === $schedule) {
throw new RuntimeException('Failed to create new Mage_Cron_Model_Schedule model');
}
try {
$timestamp = strftime('%Y-%m-%d %H:%M:%S', time());
$schedule->setJobCode($jobCode)->setStatus(Mage_Cron_Model_Schedule::STATUS_RUNNING)->setCreatedAt($timestamp)->setExecutedAt($timestamp)->save();
call_user_func_array($callback, array($schedule));
$schedule->setStatus(Mage_Cron_Model_Schedule::STATUS_SUCCESS);
} catch (Exception $cronException) {
$schedule->setStatus(Mage_Cron_Model_Schedule::STATUS_ERROR);
}
$schedule->setFinishedAt(strftime('%Y-%m-%d %H:%M:%S', time()))->save();
if (isset($cronException)) {
throw new RuntimeException(sprintf('Cron-job "%s" threw exception %s', $jobCode, get_class($cronException)), 0, $cronException);
}
if (empty($callback)) {
Mage::throwException(Mage::helper('cron')->__('No callbacks found'));
}
}