Email send action fails: Cron has been running for more than an hour and is most likely stuck I am maintaining a Drupal 6 installation. The task was to send an email to all registered users. I was using a rule set containing one rule with a default action: "send email to all users of a certain role". The rule set has been scheduled, was executed and deleted from the schedule (automatically like expected), but the task seemed to restart forever in the background: all (or probably a lot) users got the email every hour (6 times until I stoped cron). I use poormans-cron.

Please help with to answer this questions:


I suppose the mails could not be sent (~300 users) in the 60 minutes before the next cron (1h) decided that the job was still not complete and restarted it. Correct?
300 mails in 1 hour should not be a problem, but I saw somewhere, but cannot remind where, that one can set a wait time between sending mails. Is that correct? Please tell if you know where.
Can you think of something else than 1. for the reason? (I used out of the box drupal 6 functions).


The log shows:

error   cron    18/02/2012 - 12:04  Cron has been running for more than an hour and is most likely stuck.
warning cron    18/02/2012 - 11:08  Cron run exceeded the time limit and was aborted.
error   cron    18/02/2012 - 11:04  Cron has been running for more than an hour and is most likely stuck.
warning cron    18/02/2012 - 10:07  Cron run exceeded the time limit and was aborted.
error   cron    18/02/2012 - 10:03  Cron has been running for more than an hour and is most likely stuck.
warning cron    18/02/2012 - 09:07  Cron run exceeded the time limit and was aborted.
error   cron    18/02/2012 - 09:03  Cron has been running for more than an hour and is most likely stuck.
error   cron    18/02/2012 - 09:02  Cron has been running for more than an hour and is most likely stuck.
error   cron    18/02/2012 - 07:50  Cron has been running for more than an hour and is most likely stuck.
warning cron    18/02/2012 - 06:46  Cron run exceeded the time limit and was aborted.


Appendix 1, 19.2.2012
I use PHPMailer module to send the emails.
I think that your PHP configuration is not letting cron finish. Turn off poormanscron, then delete your cron entries in your MySQL database:

DELETE FROM `variable` WHERE name = 'cron_semaphore';
DELETE FROM `variable` WHERE name = 'cron_last';


Then go to admin/reports/status and click on your PHP version to see the output of phpinfo(). What is the max execution time? What is the memory limit? You'll want to change those values to higher numbers, then verify that they are indeed different on this page, then run cron manually at admin/reports/status. 

To change these 2 values in PHP, create (or edit) php.ini in the webroot of your site and add (or modify):

max_execution_time = 300
memory_limit = 256M


Obviously feel free to try whatever numbers you'd like here. Ideally you don't want to leave the memory limit very high if you don't need to.