How to make your drupal cron run longer
No, that is not a dodgy innuendo - this is infact a quick hint on how to extend the running time of your cron script for drupal - particularly handy if you keep getting “script execution time exceeded” type errors (i.e.”Fatal error: Maximum execution time of 30 seconds exceeded”) try the following
1. Edit cron.php - stick the following at the top of the script
$_SERVER["HTTP_HOST"] = 'YOURHOSTNAME';
// ^ e.g. 'sourceymonkey.com' - should be the same name as your config folder in sites
// NB: this is so you can run the script from the command line (and thus remove a browser timeout problem) - if you don't have line command access then there is no need for this
$_SERVER["PHP_SELF"] = '/cron.php';
// may need to change that if your site is in a subdirectory. e.g. 'site/cron.php'
2. Edit includes/common.inc
Open the file up.
search for ‘set_time_limit’ (in drupal 5.1 its on line 1982)
change the time in the function so:
set_time_limit(24000);
should do the trick (that’s quite a while!)
3. Now go the root of your install and type:
php ./cron.php
(If you haven’t got line command access just set off the cron script as usual: http://YOURSITE/cron.php)
4. Go and make a cup of tea!
5. Check your logs to see what happened!
Its a nasty hack but one that may help those timeout headaches!
Enjoy!