Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: Optimization of cron.php

Submitted by on July 21, 2010 – 9:06 amNo Comment

 

You need to run cron frequently (for example, every 10 minutes). And meet some problems on this way.

Modules launched by cron work with external sites and connection with them can be bad or script is disabled by timeout set in PHP.ini. It’s ok, but cron spoils the whole thing. It implements  this operation in an hour and then says that time for routine procedures is more than an hour and the system hangs up. over an hour, most likely the system is hanging up.

Solution

When cron runs, Drupal sets "cron_semaphore" variable to the current time to make sure only one cron is launched in the meantime. You can change 2507 line in /includes/common.inc file (this is drupal_cron_run function) if you know exactly that cron won’t work more than 5 minutes:

  if ($semaphore) {
    if (time() – $semaphore > 3600) {
      // Either cron has been running for more than an hour or the semaphore
      // was not reset due to a database error.
      watchdog(‘cron’, ‘Cron has been running for more than an hour and is most likely stuck.’, array(), WATCHDOG_ERROR);
      // Release cron semaphore
      variable_del(‘cron_semaphore’);
    }
    else {
      // Cron is still running normally.
      watchdog(‘cron’, ‘Attempting to re-run cron while it is already running.’, array(), WATCHDOG_WARNING);
    }
  }

Try to change change ‘3600’ to maximal time of working your cron-script (in seconds) in 2507 line. This error will disappear (but of cause other errors can occur;)

Thus if you set semaphore to 10 minutes and cron is launched every 6 minutes then if cron hangs it will be launched again.

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.