title: Magento cron job expression dynamically
body: <p>i am trying to set up a cron job dynamically in my custom module. but this do not save the job_code to cron_schedule table. </p>
  
  <pre><code>  &lt;config&gt;
      &lt;crontab&gt;
      &lt;jobs&gt;
      &lt;bookingreservation_summary&gt;    
           &lt;!--&lt;schedule&gt;&lt;cron_expr&gt;*/5 * * * *&lt;/cron_expr&gt;&lt;/schedule&gt;--&gt;     
          &lt;run&gt;&lt;model&gt;bookingreservation/observer::sendBookingSummaryEmail&lt;/model&gt;&lt;/run&gt;
      &lt;/bookingreservation_summary&gt;
      &lt;/jobs&gt;
     &lt;/crontab&gt;
   &lt;/config&gt;
  </code></pre>
  
  <p>And the cron_expr is commented, because i am generating it from configurations. and this saves expression and model in config_data table like,</p>
  
  <pre><code> path: crontab/jobs/process_bookingreservation_summary/schedule/cron_expr  
   value: 0 17 * * *
  
   path : crontab/jobs/process_bookingreservation_summary/run/model
   value : bookingreservation/observer::sendBookingSummaryEmail
  </code></pre>
  
  <p>this class executes and saves into config_data</p>
  
  <pre><code> class ABC_Bookingreservation_Model_Config_Backend_Cron extends Mage_Core_Model_Config_Data
      {
  const CRON_STRING_PATH  = 'crontab/jobs/process_bookingreservation_summary/schedule/cron_expr';
  const CRON_MODEL_PATH   = 'crontab/jobs/process_bookingreservation_summary/run/model';
  
  /**
   * Cron settings after save
   *
   * @return Mage_Adminhtml_Model_System_Config_Backend_Log_Cron
   */
  protected function _afterSave()
  {
      $enabled    = $this-&gt;getData('groups/booking_summary/fields/enabled/value');
      $time       = $this-&gt;getData('groups/booking_summary/fields/time/value');
      $frequncy   = $this-&gt;getData('groups/booking_summary/fields/frequency/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;
  
      if ($enabled)
  {
          $cronDayOfWeek = date('N');
          $cronExprArray = array(
              intval($time[1]),                                   # Minute
              intval($time[0]),                                   # Hour
              ($frequncy == $frequencyMonthly) ? '1' : '*',       # Day of the Month
              '*',                                                # Month of the Year
              ($frequncy == $frequencyWeekly) ? '1' : '*',        # Day of the Week
          );
          $cronExprString = join(' ', $cronExprArray);
      }
      else{
  
          $cronExprString = '';
      }
  
      try
      {
          Mage::getModel('core/config_data')
              -&gt;load(self::CRON_STRING_PATH, 'path')
              -&gt;setValue($cronExprString)
              -&gt;setPath(self::CRON_STRING_PATH)
              -&gt;save();
  
          Mage::getModel('core/config_data')
              -&gt;load(self::CRON_MODEL_PATH, 'path')
              -&gt;setValue((string) Mage::getConfig()-&gt;getNode(self::CRON_MODEL_PATH))
              -&gt;setPath(self::CRON_MODEL_PATH)
              -&gt;save();
      }
      catch (Exception $e)
      {
          Mage::throwException(Mage::helper('adminhtml')-&gt;__('Unable to save the cron expression.'));
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>can any one help where is issue with my code, because whenever i run cron.php through browser cron_scedule table updates, but do not save job_code from this job.</p>