The S-Files: Cron run exceeded the time limit and was aborted.
by Robert Douglass
Tech Support Case Studies
Our support team is prepared to deal with any Drupal related problem or question that might arise. Some problems show up more often than others, though, and in those cases it is good to have the solutions at your fingertips.
This recently got added to our growing library of Drupal knowledge, and deals with the problem of running cron efficiently. In the effort to tune PHP to perform well while serving normal web pages, it is possible to set some values in php.ini so low that they are insufficient for running cron.
Two such values are
memory_limit. You want both of these to be as low as you can get away with because then you have more resources available for serving more page views.
This will bite you, though, if you have cron tasks that need extra time or memory. You'll know this is happening because you'll have Cron run exceeded the time limit and was aborted. as an error message in your logs.
The solution, on Ubuntu, Debian, and most other modern Linux distributions, is to take advantage of the fact that there are two php.ini files. One for Apache, and one for CLI (the command line interface). On Debian and Ubuntu these are located at /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini.Tune the apache2/php.ini file for high performance, but tune the cli/php.ini file for having enough available resources to get the large jobs done. Once you've done that you can take advantage of a little known script that ships with Acquia Drupal (Drupal 6), the scripts/drupal.sh script. Here's how you'd invoke it to run cron for you:
/var/www/docroot/scripts/drupal.sh --root /var/www/docroot http://default/cron.php[/codefilter_code]
Let's break that down. The script is found in /scripts in any Drupal 6 installation. So if you have your site in /var/www/docroot, the script will be at /var/www/docroot/scripts/drupal.sh. The --root parameter tells the script where your Drupal docroot is. The final parameter will be "http://default/cron.php". Exactly like I just typed it. Not adjusted in any way to the name of your site, or anything else. Just "http://default/cron.php".
You can try running the script and checking your logs to see if cron is being invoked. Once you've nailed the syntax of running the command, add it to your crontab for regular cron execution:
*/1 * * * * /var/www/docroot/scripts/drupal.sh --root /var/www/docroot http://default/cron.php > /dev/null 2>&1