Results 1 to 5 of 5

Thread: Server, let the user go!

  1. #1
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default Server, let the user go!

    I have a php script that is suppose to run in the background of the server on a very very long loop. The problem is that a user has to call the script for it to begin. Is there a way to cut the users connection to the script? In other words:
    PHP Code:
    <?php
    ignore_user_abort
    (true);
    set_time_limit(0);

    header("Location: ./page.php"); //CUT THE USER'S CONNECTION HERE!

    $x=0;
    do{
        
    $x++;
        
    sleep(60);
    }while(
    $x<1000)
    ?>
    Otherwise the user has to push the stop button or wait until the timer runs out. Right now the header does nothing until the loop ends-- and the loop doesn't end before the user times out.

    Or perhaps there is a way to run the script in another way, such as via the system() function? (Again, though, it would need to be called through a php script and redirect the user rather then having them stick around until they time out.)
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Someone must have an idea. Don't be shy
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  3. #3
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    you can use a Crontab for running the script

    Running PHP Scripts with Cron
    Last edited by NXArmada; 03-17-2008 at 04:44 PM. Reason: Added how to link
    Ryan
    Sevierville, TN

  4. #4
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thanks for the reply! A few questions:
    1) Can I run that from a php script?
    2) If so, how can I get the cron to run once (as opposed to every so often)?
    3) What would it return?
    I need to actually run the php loop as opposed to a cron, but if I can run the cron once to start the loop-- asuming that it will not keep the user around until the script finishes-- that would be great.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  5. #5
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    I figured it out, and it seems to be working. Thanks!
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

Bookmarks

Posting Permissions

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