Drupal Install: 6x
Server: apache
OS: fedora 16

I can run "cron" through Drupal UI, so long as I'm signed in, with no problems what so ever. But the server side execution of cron fails and reveals this error: "Cron run exceeded the time limit and was aborted." This same error is revealed when trying to run cron through the browser when not logged in. (Example: http://mysite.com/cron.php) Note: I can use the browser to go to http://mysite.com/cron.php and it run successfully as long as I was already signed in. Sorry if I'm reiterating but I want to be thorough.

I have tried many different solutions offered throughout the forums relating to changing time out variables and what not. But cron runs fine through the Drupal admin system. It only fails when I try to run it server side. This is the command I am running:

wget -O - -q -t 1 http://mysite.com/cron.php

I utilized a code snippet from a related post (http://drupal.org/node/123269) posted by: liquidcms (12th comment):

file location: includes/module.inc
function in file: module_invoke_all
String to add:

foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;

if ($hook == 'cron') watchdog('cron', "hit $module cron"); // add this line

This allowed me to see which modules where posting to the log before the cron failed and they are as follows:

dblog
filter
node <-- last one to post

Any help would be greatly appreciated. I feel like I'm going in circles at this point. My only other option that I can think of is figure out a way to run cron as an authenticated user server side and see if that works. I'll post my results once I'm done, fail or pass.

Thanks

Comments

I had a similar situation a

I had a similar situation a couple of years ago. For some reason one of my nodes was causing issues in the node search indexing. I had to track down which node it was, in a similar method to what you've done there, and then delete that node in order to get everything working.

Unfortunately I don't remember specifically which function I stuck the code into, so I can't help there. But maybe this can point you in the right direction.

Jaypan We build websites

CRON SOLUTION

Thanks for you reply Jaypan. I ended up coming across a solution last night. Turns out it did have to deal with an authenticated user issue. The solution is as follows:

So basically cron will only run properly, server side, if your an authenticated user. When I was looking at the logs, I noticed that when cron ran from the server side it was labeled as "Anonymous" and when I ran it while logged in it was "Admin" So I added this nifty little code snippet to the cron.php which should be located in your Drupal install root.

// Run as priveledged Drupal user; Place this above: drupal_cron_run();
global $user;
$user = user_load(1);

So basically this sets a global variable equal to user(1) which in my case is admin, that the server can then use to run cron as an authenticated user! Crazy how a few lines of code can fix a fairly big problem. Hope this helps future Drupal users.

nobody click here