1

I configured a script to run as part of my cron.daily tasks, and tested the script.

My status report says that the cron was correctly run by the script, so I'm happy that that will happen.

However, I went to the available updates page, and it still says that I last checked 17 hours ago - isn't this part of the cron?

Is there a way I can include this in the automated checks and reporting?

2

Looking at the code of update_cron(), I notice that the function checks for updates if there aren't cached data or if the update interval is past.

function update_cron() {
  $frequency = variable_get('update_check_frequency', 1);
  $interval = 60 * 60 * 24 * $frequency;
  // Cron should check for updates if there is no update data cached or if the
  // configured update interval has elapsed.
  if (!_update_cache_get('update_available_releases') || ((time() - variable_get('update_last_check', 0)) > $interval)) {
    update_refresh();
    _update_cron_notify();
  }
}

By default, updates are checked once per day; if you want Drupal checks for updates twice per day, you can change the value of the "update_check_frequency" variable to 0.5.
As the setting page doesn't allow you to set a value that is lower than 1, you can change the value of that variable with variable_get('update_check_frequency', 0.5). Cron tasks needs to be executed at least twice per day, or the trick doesn't work.
You can also invalidate the cache, and force update.module to check for updates the next time the cron tasks run, by visiting the page that lists all the modules and clicking on the "Save" button; alternatively, you can call update_invalidate_cache().

  • For what I remember, drupal.org was blocking the sites that were checking for updates too often. As far as I recall, this is not anymore the case, but I would not change the site to check too frequently for updates the same. – kiamlaluno Apr 28 '11 at 0:58
  • Ah, I see - so my daily cron will run the update checks every other day (if I don't change this value)? – HorusKol Apr 28 '11 at 1:11
  • Also - where is this setting? – HorusKol Apr 28 '11 at 1:11
  • 1
    @HorusKol The setting is on admin/reports/updates/settings; it just allows you to choose between "Daily" (the default value), and "Weekly." With the default value, updates are checked every day. I have updated the answer with two different ways to allow update.module to check for updates more than once per day. – kiamlaluno Apr 28 '11 at 1:22
  • all working fine this morning, so all good - thanks :) – HorusKol Apr 29 '11 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.