0

I am having trouble running cron.php. For testing, I am just running it from the browser (my_domain/my_site/cron.php.) Basically, if I go into the database and delete cron_last from the variable, it works fine, for one iteration, but the next time I try to run it, it doesn't work (until I delete the cron_last value again)

I put watchdog statement in cron.php. From that I could see that it runs until it hits drupal_cron_run. That statement doesn't execute correctly.

drupal_cron_run in in common.inc, so I put more watchdog statements in there. It fails to run past module_invoke_all('cron').

module_invoke_all is in module.inc, so I looked in there, but now I'm stuck. Any ideas?

  • Is it Drupal 6? – Mołot Nov 6 '13 at 7:49
0

Basically, you can't delete it with your code - it's set up after last cron hook finishes, so no matter what you do inside Drupal, it'll be set. If the last line that gets executed is module_invoke_all('cron') (in Drupal 6) or module_invoke_all('cron_queue_info'); (in Drupal 7 real cron tasks are wrapped in try catch so this is the only really risky point), or if your server logs timeouts, it's probably a faulty module that fails to execute it's hook_cron, or too many modules defining it, so at some point it times out.

I see two ways to deal with it:

  1. Use Elysia Cron and with it's GUI manually run cron tasks you need to test. That way even if single task will fail, other will get executed. they will be executed one at a time, if you set it up correctly, so less risk of a timeout. And you will be able to test which hook, exactly, fails to execute. Then simply uninstall faulty module, or fix it, and you'll be OK.
  2. In MySQL, create a trigger that will delete cron_last value for you. PostgreSQL supports triggers too, and most of RDBMS support them or something similar to them. It will not solve your problem, but it's way faster than point 1. and it will get you going if all you need is quick and dirty hack.

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.