How to abort a cron run? I would like to have the ability to prevent cron from running based on a variable set in the database. I have created a hook_cron implementation in a module with an extremely low weight so it will presumably run before all other module's cron hooks. Within that function I then check the variable and call exit() to abort PHP's execution. This seems to work but is there a more elegant way to prevent cron from continuing? Calling exit() seems a bit harsh and I am concerned about unintended consequences. Example code below.

function ex1_cron() {
  if (variable_get('ex1_var', 1) === 1) {
    watchdog('ex1', 'Cron is being aborted.', array(), WATCHDOG_WARNING, NULL);
    exit();
  }
}
Calling exit() yes is a little bit too harsh and it does bring some consequences with it:


Typically when drupal_cron_run() finishes running all the cron jobs created with hook_cron() it logs into the watchdog the message "Cron run completed". Aborting your cron cycle mid-execution leaves you with no traces of how or when your cron finished.
When the cron cycle begins, Drupal creates a cron lock by using variable_set('cron_semaphore', time());, which prevents further cron cycles from running until you release the sempahore (manually) or until 3600 seconds pass since the last time you aborted the cron.


When your abort condition is met, you should at least do the following:

// Call cleanup function.
drupal_cron_cleanup();

// Release cron semaphore
variable_del('cron_semaphore');

watchdog('name_of_yourmodule', 'Aborted because XYZ.', array(), WATCHDOG_ERROR);


Also like @wiifm mentioned in his answer, a lot of critical functions defined by core and contrib depend on cron running to keep your site working. Abort cron and your site suddenly stops running smoothly. I would really avoid doing this.