I've just launched my site and haven't set up crontab yet, I've been running cron manually. I just received this message:

Cron has been running for more than an hour and is most likely stuck.

Help!?

Comments

kulfi’s picture

Somebody?

kulfi’s picture

Its still going ... help appreciated!

Anatsim’s picture

+1

themegarden.org’s picture

Try to "clean" cron_semaphore from your database:

USE Name_Of_Your_Drupal_Database;
DELETE FROM variable WHERE name="cron_semaphore";

It should help.

---
Drupal Themes Live Preview - themegarden.org

Anatsim’s picture

Still coming "Cron has been running for more than an hour and is most ..."
Some other ideas how to detect module, which delays cron ?

themegarden.org’s picture

What is result of next query:

SELECT * FROM variable WHERE name like "cron%";

If you find 'cron_semaphore' under field 'name', try query from my prev. post (REMOVE FROM ...), and than repeat this query.
After that, run cron.php manually.
Does msg "Cron has been running for more than an hour and is most ..." apear after first cron job (just after "cleaning" database)?
If yes, then I don't have any clue.

Otherwise, run cron (after 1st cron job is finished) again.

If msg still coming, than pls. give me next details.
What your web server's error log file says? Some errors, warnings ...?
What modules have you installed?

---
Drupal Theme Garden

shmooth’s picture

i managed to fix it by hacking common.inc. Line 1986 - get 'variable_get()' call to get the value of the semaphore variable - it was returning, according to the log file, the value '1187524663'.

how in the world could that happen?

so, to fix, i forced the '$semaphore' variable to FALSE (I had already tried deleting all 'cron%' entries from the db, and that did not work), ran the cron successfully through the admin menus, then removed my hacked code and now all is fine. i checked the return value of Semaphore now, and it comes back blank - when seems to be essentially correct, but i'm not too sure of that. confused about the max time of one hour and such.

the other unknowns in this mix are that i had just installed the 'Syndication' module and turned off the normal/built-in Node syndication. I also added a new feed for the News Aggregator - this new feed seemed to be giving some problems.

Still, getting that return value was really weird. And scary. The 'variable_get()' function seems to be a core part of Drupal...

/**
* Executes a cron run when called
* @return
* Returns TRUE if ran successfully
*/
function drupal_cron_run() {
  // If not in 'safe mode', increase the maximum execution time:
  if (!ini_get('safe_mode')) {
    set_time_limit(240);
  }

  // Fetch the cron semaphore
  //$semaphore = variable_get('cron_semaphore', FALSE);
  $semaphore = FALSE;

  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', t('Cron has been running for more than an hour and is most likely stuck.'), WATCHDOG_ERROR);

      // Release cron semaphore
      variable_del('cron_semaphore');
    }
    else {
      // Cron is still running normally.
      watchdog('cron', t('What in the world is going on here? The value of $semaphore is \''.$semaphore.'\'.'), WATCHDOG_WARNING);
      watchdog('cron', t('Attempting to re-run cron while it is already running.'), WATCHDOG_WARNING);
    }
  }
...

er_lion’s picture

Hello, after setting my website in the new amazing 5.0 version I discovered that I had a really serious problem with the HEART of my website: cronjobs... After 4 or 5 times running normally it got stuck. I was almost going to 4.7 version (redoing all the work) when I discovered this entry. Thanks shmooth, apparently it works again. Only I hope that the problem won´t appear again. Did you experienced the problem again since you fixed it?

Thanks again :)

er_lion’s picture

Yes, I had to solve the problem twice more and this evening another one. The problem repeates once and again. This means that Dupal version 5.2 does not work?? Then, why it has been released?

:(

VMII’s picture

It's been released because it was tested and deemed working. I have no problems with cron on any of my sites using 5.2. Just because it is not working for you, in your environment does not mean it isn't ready. Drupal cannot be tested in all the possible environments, with all the possible combinations of modules in those environments before being released. Every piece of software , no matter how much QC is involved is released only later to find securiity problems and bugs.

I highly suggest setting up a test site and testing a fresh cron file. Then slowing working in any module sto see if there is a conflict. If there is there is the culprit.
_____________________________________________________________________________________________
give a person a fish and you feed them for a day but ... teach a person to fish and you feed them for a lifetime

kpoirier’s picture

Is there a fix for this problem? I'm running Drupal 5.1 and after deleting the cron% entries in the variable table in the database, I still have the error "Attempting to re-run cron while it is already running." and unfortunately, trying to add the line $semaphore = FALSE; on results in an error when I try to run the cron.php by hand.

Should I upgrade to 5.2? Is there any other solution to this problem? This seemed to crop up when I updated some modules - status_update being one of them but I've disabled it just to be sure.

Any input would be appreciated.

dthiessen’s picture

I'm not sure if this was stated or not but you have to delete the variables entry in the cache table as well as the cron_semaphore entry in the variables table. I was confused why It wouldn't work until I discovered this. After that just disable all contrib modules and the search module and enable them one by one, running cron each time, until you see the problem.

Todd Young’s picture

Shmooth's suggestion worked wonders - putting

$semaphore = FALSE;

into the common.inc file. I ran once and took it back out, all is well. Thank you!

alansch’s picture

Here is a somewhat more sophisticated approach that will also allow you to trace out which cron hook is causing the hang to occur.

Please refer to the issue at http://drupal.org/node/779356 which I have just submitted.

vivdrupal’s picture

Cleared cache and immediately ran cron.

sjtout’s picture

I had to increase the memory in php.ini from 32m to 64m. Other suggestions hadn't worked; that did.