Drupal 6 Fixing Stuck Cron Run
If your Drupal cron has failed, and if you see this in your Drupal 6 log, I feel your pain:
Attempting to re-run cron while it is already running.
So what is going on here? Basically, a cron run started and for whatever reason did not finished... and frankly, probably never will. So the first question:
How to I get the Drupal 6 Cron Unstuck?
This is fairly easy to do. There are three easy ways (choose the one that works for you):
- If you have drush, simply run
drush vdel cron_semaphoreenter the number 1, and hit enter. You can then re-run cron using
drush cron(This is my preferred method)
- Delete the cron_sempahore entry from the variables database table
- Wait it out. After an hour or so Drupal usually realizes that cron is stuck and will correct itself
What is causing the Drupal Cron failure in the first place
This is a good question. Here are some ideas for tracking down the issue:
- It could be an error that is occur in one of your modules hook_cron() functions
- It could be the search module (this seems to be the most common cause of Cron issues). You can try changing the search settings to index less content each cron run or perhaps an uninstall and re-install will do the trick
- Cron could be timing out in the middle of the run if you have a lot of things processing. This is handled by PHP script settings. Often if you run cron through the cron.php script, your settings will be set to something like 30 seconds. Your best bet here is to set up Drush and use
drush cronto run your cron on your Drupal 6 site. If you have questions or need the crontab settings or a simple handy script to set this up, just ask...
How do I debug cron?
This is another common question and will definitely come up if your problem lies in the first point above. For this I defer to http://drupal.org/node/553430 which provides some good debugging tips.
That's all for now.