FAQ
I am working a module that makes use of cron to fetch large amounts of
3rd party data, and then turns that data into nodes and sticks it all
into the drupal db. Each time the module goes and fetches this data
takes a large amount of time, and my module invokes a number of
different scripts to help handle the data depending on where it's coming
from. I'm running into problems where in the midst of my cronjob
executing, drupal_cron_cleanup() seems to get called somehow - the error
'Cron run exceeded the time limit and was aborted' appears in watchdog.
Does anyone have any idea what's going on and/or how I can prevent this?

Thanks so much,
Arthur

Search Discussions

  • Andrew morton at May 24, 2008 at 12:41 am

    On Fri, May 23, 2008 at 5:23 PM, Arthur Richards wrote:
    I'm running into problems where in the midst of my cronjob
    executing, drupal_cron_cleanup() seems to get called somehow - the error
    'Cron run exceeded the time limit and was aborted' appears in watchdog.
    Does anyone have any idea what's going on and/or how I can prevent this?
    I think your best bet would be to try to break your task up into
    smaller chunks and call cron more frequently. You could also try
    extending PHP's script timeout limit (http://php.net/set_time_limit).

    andrew
  • Arthur Richards at May 24, 2008 at 2:25 am
    Andrew,

    Thanks - I've already done that though. In fact, I have turned the time
    limit off (set_time_limit(0)). I don't think the problem is the size or
    duration of my scripts - maybe it is, but the watchdog message is a
    product of drupal_cron_cleanup, which I thought isn't supposed to be
    called until everything's done running, since it's called with
    register_shutdown_function() in drupal_cron(). I can't figure out what
    could be getting drupal_cron_cleanup to execute before my cron scripts
    finish.


    Message: 9
    Date: Fri, 23 May 2008 17:41:53 -0700
    From: "andrew morton" <drewish at katherinehouse.com>
    Subject: Re: [development] cron woes - drupal_cron_cleanup() kills my
    cronjob while it's still running...
    To: development at drupal.org
    Message-ID:
    <fab053ce0805231741h5a8cb7e6s74919a45f6e498fd at mail.gmail.com>
    Content-Type: text/plain; charset=ISO-8859-1
    On Fri, May 23, 2008 at 5:23 PM, Arthur Richards wrote:

    I'm running into problems where in the midst of my cronjob
    executing, drupal_cron_cleanup() seems to get called somehow - the error
    'Cron run exceeded the time limit and was aborted' appears in watchdog.
    Does anyone have any idea what's going on and/or how I can prevent this?
    I think your best bet would be to try to break your task up into
    smaller chunks and call cron more frequently. You could also try
    extending PHP's script timeout limit (http://php.net/set_time_limit).

    andrew
  • Andrew morton at May 24, 2008 at 2:48 am

    On Fri, May 23, 2008 at 7:25 PM, Arthur Richards wrote:
    Andrew,

    Thanks - I've already done that though. In fact, I have turned the time
    limit off (set_time_limit(0)). I don't think the problem is the size or
    duration of my scripts - maybe it is, but the watchdog message is a
    product of drupal_cron_cleanup, which I thought isn't supposed to be
    called until everything's done running, since it's called with
    register_shutdown_function() in drupal_cron(). I can't figure out what
    could be getting drupal_cron_cleanup to execute before my cron scripts
    finish.
    I think you're still running into the script time limit. When that
    happens, PHP will fire the shutdown functions and
    drupal_cron_cleanup() gets called. Perhaps you've got safe mode
    enabled? That would explain the timeouts even after calling
    set_time_limit(). My recollection though was that trying to call
    set_time_limit() in safe mode resulted in a warning/error.

    You might want to look for additional clues here:
    http://us2.php.net/manual/en/info.configuration.php#ini.max-execution-time

    andrew
  • Liam McDermott at May 24, 2008 at 4:29 am

    On Fri, May 23, 2008 at 7:25 PM, Arthur Richards wrote:
    Thanks - I've already done that though. In fact, I have turned the time
    limit off (set_time_limit(0)). I don't think the problem is the size or
    duration of my scripts - maybe it is, but the watchdog message is a
    product of drupal_cron_cleanup, which I thought isn't supposed to be
    called until everything's done running, since it's called with
    register_shutdown_function() in drupal_cron(). I can't figure out what
    could be getting drupal_cron_cleanup to execute before my cron scripts
    finish.
    Another cron would cause those functions to be run. If the cron
    semaphore in {variables} is older than one hour, cron will delete it and
    run again (if I remember correctly).

    The problem is almost certainly the duration of time those scripts are
    taking to run. Processing information in smaller chunks (or splitting up
    any complex queries) will stop this problem and be less strain on the
    server. :)

    There's some cool batch malarkey in Drupal six that could help you:
    http://api.drupal.org/api/group/batch/6

    Kind Regards,
    Liam McDermott.
  • Neil Drumm at May 26, 2008 at 2:16 am

    On Fri, May 23, 2008 at 7:48 PM, andrew morton wrote:
    On Fri, May 23, 2008 at 7:25 PM, Arthur Richards wrote:
    Andrew,

    Thanks - I've already done that though. In fact, I have turned the time
    limit off (set_time_limit(0)). I don't think the problem is the size or
    duration of my scripts - maybe it is, but the watchdog message is a
    product of drupal_cron_cleanup, which I thought isn't supposed to be
    called until everything's done running, since it's called with
    register_shutdown_function() in drupal_cron(). I can't figure out what
    could be getting drupal_cron_cleanup to execute before my cron scripts
    finish.
    I think you're still running into the script time limit. When that
    happens, PHP will fire the shutdown functions and
    drupal_cron_cleanup() gets called. Perhaps you've got safe mode
    enabled? That would explain the timeouts even after calling
    set_time_limit(). My recollection though was that trying to call
    set_time_limit() in safe mode resulted in a warning/error.

    You might want to look for additional clues here:
    http://us2.php.net/manual/en/info.configuration.php#ini.max-execution-time
    In this situation, I run cron using drupal.sh in Drupal 6, it does
    work fine with Drupal 5 too:
    drupal.sh --root /path/to/drupal http://sites.directory.name/cron.php

    This uses the separate php.ini for CLI and keep restrictions for Apache.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdevelopment @
categoriesdrupal
postedMay 24, '08 at 12:23a
activeMay 26, '08 at 2:16a
posts6
users4
websitedrupal.org
irc#drupal

People

Translate

site design / logo © 2022 Grokbase