Ultimate Cron. Invoke a cron from a cron. Set a cron enabled status to TRUE till its queue gets empty. Then set it to FALSE I am using Ultimate Cron for running individual cron runs and I see Ultimate Cron provide hook_cronapi() to create own cron task runs and provide enabled key as either TRUE or FALSE.

My objective is create two cron task one cron will run at specified time say 01:00pm and will update the enabled statues of second cron to TRUE so that it will run until it achieved certain condition  during each 1 min interval of this second cron task and after this condition is met, will be shut down the second cron task status by setting disabled status to FALSE so that it stop processing uselessly.

So, how do I set that enabled status to TRUE/FALSE during its run time.
Answering my own question.

In your .info file first define ultimate_cron as dependencies

dependencies[] = ultimate_cron


Next, in your .module use hook_cronapi() and define two cron attributes.

/**
 * Implements hook_cronapi().
 */
function mymodule_cronapi() {
  $items = array();
  // This launches at specified time once a day.
  $items['custom_cron_1'] = array(
    'title' =&gt; t('This will run once every day'),
    'scheduler' =&gt; array(
      'name' =&gt; 'crontab',
      'crontab' =&gt; array(
        'rules' =&gt; array('* 2 * * *'),
    ),
  );
  // Run only when invoked and until &amp; unless condition is met so we are not left for tomorrow
  $items['custom_cron_2'] = array(
    'title' =&gt; t('Run when invoked'),
    'enabled' =&gt; FALSE,
    'scheduler' =&gt; array(
     'name' =&gt; 'crontab',
     'crontab' =&gt; array(
       'rules' =&gt; array('*/1 * * * *'),
     ),
  );
  return $items;
}


Next step is to define the cron job callback and here in first callback we will schedule to run second cron job.

function custom_cron_1() {
  $job = _ultimate_cron_job_load('custom_cron_2');
  // Enable the job.
  $job-&gt;enable();
}


Next we will define callback for second cron and continue this cron process each minute until condition is met.

function custom_cron_2($job) {
  // Check for condition.
  if(...) {
    $job-&gt;disable();
  }
  else {
    // Continue the process
  }
}