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 6 of 6

Thread: script exe time

  1. #1
    Regular Coder
    Join Date
    May 2006
    Posts
    107
    Thanks
    1
    Thanked 0 Times in 0 Posts

    script exe time

    Hello all

    I want to execute some script for some time like say I want to run a piece of code for around 2 minutes and then stop it is that possible? and if its possible how can i do so using php?

    thank you
    dizyn

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you check set_time_limit() function, i think that it should help you
    If you can not find a decision, maybe you have to try to change a problem

    http://www.gunman.co.nr
    http://bglinux.org

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Did you check set_time_limit() function, i think that it should help you
    This has nothing to do with the question. Did you even read it?

    I want to execute some script for some time like say I want to run a piece of code for around 2 minutes and then stop it is that possible? and if its possible how can i do so using php?
    You could use sleep.

    If you need to do something every X minutes, you will need to use cron jobs, or something similar if your server does not allow them.

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    sleep() will stop script execution, not quite sure how that makes more sense than gunman's suggestion ?

    PHP Code:
    <?php
    set_time_limit
    (125);
    $finish=mktime()+120;
    while(
    mktime() <= $finish){
        
    //DO STUFF
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    sleep() will stop script execution, not quite sure how that makes more sense than gunman's suggestion ?
    I want to run a piece of code for around 2 minutes and then stop it
    PHP Code:
    <?php
        sleep
    (120);
    ?>
    It's a piece of code that runs for 2 minutes and then stops.

    It'd be wrong of me to assume that the user wants to run some calculations/processing code with a time limit of 2 minutes.

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    Quote Originally Posted by aedrin View Post
    It'd be wrong of me to assume that the user wants to run some calculations/processing code with a time limit of 2 minutes.
    say I want to run a piece of code for around 2 minutes and then stop it is that possible?
    Quote Originally Posted by aedrin View Post
    This has nothing to do with the question. Did you even read it?
    did you ?, only the original poster knows what they want, perhaps they will qualify, and perhaps until then you could give others trying to help a break
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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