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

spjsche - January 2, 2007 - 20:07

I am running cron manually from the "status" page because it is on windoze, and poormanscron is not yet available for V5.0rc1.

Everytime I try to run it, the above is reported in my logs.

How do I unstick it, and is there any way to find out where it is stuck.

It has been like that for over 12 hours now.

Thanking you in anticipation.

Same problem here (V5.0rc1

Pancho - January 14, 2007 - 16:47

Same problem here (V5.0rc1 on Linux w/o root access)...

When I manually run cron, the log regularly shows: Cron has been running for more than an hour and is most likely stuck.

When I try to re-run cron, it logs: Attempting to re-run cron while it is already running.

How can I stop the ever-running cron?

---

Background: I tried to install the HEAD version of poormanscron, but it fired crontabs every few seconds though configured to fire only every hour... this considerably slowed down my site, produced a lot of "Error 500s", and therefore I uninstalled it again until it's bugs are resolved.

Cron 14.01.2007 - 15:25 Executed node_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed filter_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed node_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed filter_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed persistent_login_cron via poormanscron, took 0 ... Webmaster
Cron 14.01.2007 - 15:25 Executed image_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed watchdog_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed statistics_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed search_cron via poormanscron, took 14 Sekunden. Webmaster
Cron 14.01.2007 - 15:25 Executed node_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed filter_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed node_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed filter_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed persistent_login_cron via poormanscron, took 0 ... Webmaster
Cron 14.01.2007 - 15:25 Executed image_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed watchdog_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed statistics_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed search_cron via poormanscron, took 14 Sekunden. Webmaster
Cron 14.01.2007 - 15:25 Executed node_cron via poormanscron, took 0 Sek.. Webmaster
Cron 14.01.2007 - 15:25 Executed filter_cron via poormanscron, took 0 Sek.. Webmaster

Pancho, Thanks for the

spjsche - January 14, 2007 - 18:54

Pancho,

Thanks for the comments, I thought I was the only one having problems with cron.

I must admit I was inserting quite a lot of data, in the nodes, and unless you run cron regularly, then this could be an issue.

I do not know what the answer is, because one does not know where cron is getting stuck.
I noticed you produced some logs about what cron is doing, may I ask you how you managed it.
One problem is that I am running on windoze.

Does the same thing happen to you even if you run cron via the crontab ?

Thks

Cron stuck

fm000184 - January 16, 2007 - 19:21

Same here v5.0RC1 ( http://www.flyforfun.be )

I only add one or two articles a week so the amount of data cannot be the issue ?
Is the cron stuck status saved in the db anywhere in the variables table maybe ?

I would also like pointers to getting logging, I am running on a hosted machine and only have FTP and HTTP access (no terminal/ssh) so I have to rely on what the logging pages show.

Frank

Poormanscron is now

spjsche - January 17, 2007 - 13:23

Poormanscron is now available for 5.0, and it provides an option for logging the progress of cron.
Perhaps this will indicate the issues.

I have installed version 5.0, but I have not yet got to the stage of populating the site as I am having other issues.

Logging with poormanscron + cron got UNstuck !

fm000184 - January 17, 2007 - 20:00

OK,

so now I have poormanscron installed on v5 (an upgraded RC1 to v5). Poormanscron does not give me any error (I enabled all the logging). This looked OK, but, in the status page, it still said that cron was run 4 days ago and in the search settings I see that only 89% of my site is indexed (setting is index max of 10 items per cron run). In addition, it then ran EVERY time a page is called (poormanscron that is), though I left it on the default setting of 60 minutes...

I suspected from where the logging stopped that the search index did not work correctly for some reason. Tried deleting the search index (re-index site button in search settings) and that worked, now the cron runs normally through poormanscron but NOT through running it manually from the status page. That still produces an error ?!

(UPDATE) Mmmm... maybe that was my cache still working or so. I now have a full working cron again, I suspect not due too poormanscron but it is the extensive logging of this module that pointed me the right way. I'LL USE THIS MODULE from nowon as default cron runner... THANKS for poormanscron.

Frank

Well Done

spjsche - January 17, 2007 - 22:06

Well Done

Uninstalled Poormanscron

fm000184 - January 21, 2007 - 14:41

After a couple of days I had to stop poormanscron becase fo following error appearing a couple of thousand times in the logs :

[Sat Jan 20 17:42:16 2007] [error] [client 192.168.200.10] PHP Warning:  mysql_errno(): 7 is not a valid MySQL-Link resource in /var/www/fff/includes/database.mysql.inc on line 163, referer: http://www.flyforfun.web/?q=airplane

Cron in stuck again! It is only the re-indexing of the site that seems to unlock it temporarily.

UPDATE :
After adding a lot of watchdog code I found that the real problem was a routine in the node module getting stuck on a specific node (which was my homepage!). I cleared all text en meta tags (nodewords module) from my homepage and ran cron again. It ran just fine. I re-added the text in the rich text editor (not by copying the old HTML !) and it still runs fine. Apparently something in the HTML corrupted the workings of the update_index routine in the node module ?

You can mail me ( frank@raac.be )for the updated poormanscron / search and node module code that do the EXTENSIVE logging and it shows you exactly on which node the cron job fails.

Kind regards and happy cronning,

Frank

Thanks for the update, but I

spjsche - January 21, 2007 - 16:56

Thanks for the update, but I am still trying to sort out some other issues.
When I begin to populate my site, and start having cron issues I will be in touch.

Thanks for your time.

Stephen

update database manually, disable cache

housetier - January 23, 2007 - 21:24

Hello

I had the same problem with Drupal 5.0. Checking the source code I found out the cron function uses (among others) http://api.drupal.org/api/head/function/variable_del. This function deletes rows from the database.

So I did the same using phpmyadmin: One by one I deleted all rows starting with "cron" and then disabled the cache. Upon running cron again I finally saw the message "Cron ran successfully". Now I have enabled cache again and still cron seems to finish successfully.

Maybe this will help others as well.

But please do make backups!

Good point, the only thing

spjsche - January 23, 2007 - 22:30

Good point, the only thing is that because I am testing locally, I have never ever switched cache on. I only switch it on when I am happy all is working.

But I will keep my eye on naughty cron, and see what happens as soon as I start populating the system.

Thanks for the pointer.
Stephen

It worked well

x44x44 - May 5, 2007 - 17:07

housetier thank you very much. I had same problem and i also cleared cron% in phpmyadmin and disable enabled cache, so it works again. Thanks...

Those other things didn't work

NancyDru - May 24, 2007 - 17:04

So I tried the only thing I could think of that really needs Cron - I disabled the Update_Status module. Then it worked. During the Cron run, Update_Status has to go to the DO web site to get module information. I'm guessing that the poor response time caused the module serious problems - but 3 days is a bit too much!

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

I'm baffled

zbricoleur - August 20, 2007 - 15:35

I'm having the same problem: "Cron has been running for more than an hour and is most likely stuck" Furthermore, it's been stuck for days, and the only halfway informative page I can Google up on the problem is this thread--whic does not solve the problem for me.

So I'm looking at the watchdog module to see what would make it return this error message, and I am baffled. Here is the relevant bit of code:

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);

  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');
    }

But the thing is, there is NO "cron_semaphore" variable in the variable table for my site. So, as I read it, it should just skip on to the "else" clause--but it doesn't. So, if someone could point out to me where I'm mistaken, I'd appreciate it. I really need to get this fixed--0% of my site is indexed, so my search box is kaput.

Do you use Update Satus?

NancyDru - August 20, 2007 - 16:31

Running Cron manually works at first but eventually exceeds mem

glend - March 24, 2008 - 21:33

I've got a similar issue (Drupal 5.3). Here's what I've done:
Under admin/settings/search, Re-index site.
Go to admin/logs/status, run Cron manually: Cron fails.
Go to admin/logs/watchdog: error message, attempting to rerun Cron while it's already running.

So:
In phpmyadmin, I do a search for Cron through all tables
Delete one in table cache, and delete all four in table variables
Go to admin/settings/search, set index per run to 10
Go to admin/logs/status, run Cron manually: Success...

However: this indexes only 13% of my site. So I run Cron again. And again...
On the seventh time, I get
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 3600 bytes) in /home/www/.../site/includes/image.inc on line 308

And I can't go back and run cron again without first going back and reindexing and deleting the variables.

I've tried increasing my memory using htaccess and settings.php, but those haven't yielded any changes, and I don't have access to my php.ini file.

This is a pretty small site right now, it's only 72 pages, most of which are blank placeholders... I don't understand why running cron jobs with the minimum settings is more than it can handle. Why does it seem that each Cron job takes more memory than the last until it eventually exceeds my limits? I thought the whole point of using Cron jobs was that you could break your processor intensive jobs up into little chunks... Do I need to wait a few minutes between runs?

edit: this happens when I run cron manually either through the admin interface or by typing it directly into the browser.

Delete only variables

NancyDru - March 24, 2008 - 23:36

You should only have to delete "cron_semaphore" and "cron_last". You really don't need to clear the search stuff at all.

As for the memory problem, I'm guessing that's some module with a hook_cron that has a problem. I doubt that it's search.module.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

Delete only variables

NancyDru - March 25, 2008 - 00:19

You should only have to delete "cron_semaphore" and "cron_last". You really don't need to clear the search stuff at all.

As for the memory problem, I'm guessing that's some module with a hook_cron that has a problem. I doubt that it's search.module.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

Don't forget to empty cache

aaustin - July 28, 2008 - 17:53

The cache table caches a serialized version of the variable table, so after you delete "cron_semaphore" and "cron_last" from your system table, you need to either delete the variables row in your cache table or empty the cache table. Otherwise, Drupal will just use the cached version of the variables.

 
 

Drupal is a registered trademark of Dries Buytaert.