Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post

    export cron job?

    Hey,

    we have various massive exports which are run on our application - they generally take a couple of minutes to produce an XLS file (its financial data).. the trouble is, now the people above have asked for more detailed reports, which is now resulting in the files taking upto 5 minutes to be produced, and in IE the browser is just timing out. (seems ok in FF)

    I was using the web control panel and the backup on that seems to say "the backup has been placed in a queue. you will receive a notification once complete". How can I do a similar thing?

    does it create a CRON job for that request or something? I cannot think of another way to call the export PHP script in the background and get it to run without the user seeing it.

    any ideas?!

    Edit:
    ive wondered about having a single CRON job say "fetch_requests.php" which is called every 2 minutes. Then if someone requests an export, it will add their request to the database. The CRON script will check the database for any requests, and perform the export based on the values stored in the DB. Is there any implications on the server if it's checking the DB every 2 minutes?!
    Last edited by homerUK; 09-01-2006 at 11:35 AM. Reason: other idea!

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    when they request the 'build' start the job via AJAX and for the timeout problem do a rolling report.

    timeBox the job to say, 60 seconds. after 60 seconds call a 'submit, load, and continue' method.

    hrmm, how can i better explain this.

    say it is 10 000 xml nodes.

    after writing the first 1000, save the file as is, then run the process again starting where you left off.

    while this is all happening you shouldn't reveive a timeout on the page (because your using ajax), and the users can visually see the process.

    maybe add a little 'generating' box and each itteration of the script increment the percentage?

    i would go with the Cron Job solution last. as it is very strenous on the server and would possibly kill your bandwidth.

    also, if my solution does not fit you can look into hidden frames containing the php code, execute from there and make callbacks to the parent via javascript.

    Hope this helps.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    thanks for the reply - your example seems perfect! Cant believe I never thought of doing that before! It'd be nice to show a user a percentage complete too, rather than a simply "Please wait" message.

    Just out of interest, what is a timeBox?

    I was thinking of doing a mysql_num_rows() query to work out the total rows for the job, then work a percentage from that?

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    timebox is a method to not allow yourself to go over a said amount of time for a said tast. in your case you'll want to find the server timeout. and make your a bit smaller.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •