apache +php +time limits

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nichu

    apache +php +time limits

    Hello
    I set max_execution_t ime to 30 in php.ini file (i also checked in
    phpinfo). max_input_time is set to 45.

    But when I use in script something like that:

    while ( 1 == 1 )
    or
    for ( $i=0; $i < 100000000000000 000000000000000 00000000000; $i++)

    {
    echo "\n".$i;
    }


    it doesn't work - execution of script lasts for unlimited time.

    of course I executed it via apache (I read that this limit doesn't work
    while executing in console)

    is it bug or am i doing something wrong?

    regards
    nichu
  • macca

    #2
    Re: apache +php +time limits

    did you restart the server after setting the max execution time?

    Comment

    • Nichu

      #3
      Re: apache +php +time limits

      macca wrote:
      did you restart the server after setting the max execution time?
      of course ... YES - i restarted ...

      Comment

      • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

        #4
        Re: apache +php +time limits

        Nichu escribió:
        I set max_execution_t ime to 30 in php.ini file (i also checked in
        phpinfo). max_input_time is set to 45.
        >
        But when I use in script something like that:
        >
        while ( 1 == 1 )
        or
        for ( $i=0; $i < 100000000000000 000000000000000 00000000000; $i++)
        >
        {
        echo "\n".$i;
        }
        >
        >
        it doesn't work - execution of script lasts for unlimited time.
        >
        of course I executed it via apache (I read that this limit doesn't work
        while executing in console)
        I suppose you've already checked the most obvious things (restart web
        server, run phpinfo() to see if your settings have been applied...).

        An alternative could be to use this in the code itself:

        <?php
        ini_set('max_ex ecution_time', 30); // Seconds
        while(TRUE){
        }
        ?>

        It works for me where editing php.ini doesn't (e.g. console).


        --
        -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
        -- Mi sitio sobre programación web: http://bits.demogracia.com
        -- Mi web de humor al baño María: http://www.demogracia.com
        --

        Comment

        • Nichu

          #5
          Re: apache +php +time limits

          Álvaro G. Vicario wrote:
          Nichu escribió:
          >I set max_execution_t ime to 30 in php.ini file (i also checked in
          >phpinfo). max_input_time is set to 45.
          >>
          >But when I use in script something like that:
          >>
          >while ( 1 == 1 )
          >or
          >for ( $i=0; $i < 100000000000000 000000000000000 00000000000; $i++)
          >>
          >{
          > echo "\n".$i;
          >}
          >>
          >>
          >it doesn't work - execution of script lasts for unlimited time.
          >>
          >of course I executed it via apache (I read that this limit doesn't
          >work while executing in console)
          >
          I suppose you've already checked the most obvious things (restart web
          server, run phpinfo() to see if your settings have been applied...).
          >
          An alternative could be to use this in the code itself:
          >
          <?php
          ini_set('max_ex ecution_time', 30); // Seconds
          while(TRUE){
          }
          ?>
          >
          It works for me where editing php.ini doesn't (e.g. console).
          >
          >
          of course I checked phpinfo - i also checked ini_get - and both methods
          show me good value (the one I set in php.ini)

          ini_set works for me - but i want to limit execution time for all my
          users - and rather if I tell them to add this line to their scripts they
          won't listen to me ;)

          so I need to do it via php.ini

          Comment

          • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

            #6
            Re: apache +php +time limits

            Nichu escribió:
            ini_set works for me - but i want to limit execution time for all my
            users - and rather if I tell them to add this line to their scripts they
            won't listen to me ;)
            >
            so I need to do it via php.ini
            Weird... What OS and server API are you using?


            --
            -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
            -- Mi sitio sobre programación web: http://bits.demogracia.com
            -- Mi web de humor al baño María: http://www.demogracia.com
            --

            Comment

            • Nichu

              #7
              Re: apache +php +time limits

              Álvaro G. Vicario wrote:
              Nichu escribió:
              >ini_set works for me - but i want to limit execution time for all my
              >users - and rather if I tell them to add this line to their scripts
              >they won't listen to me ;)
              >>
              >so I need to do it via php.ini
              >
              Weird... What OS and server API are you using?
              >
              >
              uppps
              it was wrong diagnosis :/ sorry for that...
              generally limit works but it doesn't last for time specified in php.ini
              and it lasts ... well rather quite randomly ...

              when I set the limit to lower value (3 seconds) firstly it stopped
              script after 7 seconds, 2nd time after ~12 seconds, 3rd time ~9 seconds
              and later it last really long (after 25 seconds I stopped it manually)

              probably it has something common with caching but generally sometimes it
              lets script working for really long time (much longer than limit in
              php.ini stands for)

              by the way i'm testing it on mandriva, debian and gentoo...

              regards
              nichu

              Comment

              • Jerry Stuckle

                #8
                Re: apache +php +time limits

                Nichu wrote:
                Álvaro G. Vicario wrote:
                >Nichu escribió:
                >>ini_set works for me - but i want to limit execution time for all my
                >>users - and rather if I tell them to add this line to their scripts
                >>they won't listen to me ;)
                >>>
                >>so I need to do it via php.ini
                >>
                >Weird... What OS and server API are you using?
                >>
                >>
                >
                uppps
                it was wrong diagnosis :/ sorry for that...
                generally limit works but it doesn't last for time specified in php.ini
                and it lasts ... well rather quite randomly ...
                >
                when I set the limit to lower value (3 seconds) firstly it stopped
                script after 7 seconds, 2nd time after ~12 seconds, 3rd time ~9 seconds
                and later it last really long (after 25 seconds I stopped it manually)
                >
                probably it has something common with caching but generally sometimes it
                lets script working for really long time (much longer than limit in
                php.ini stands for)
                >
                by the way i'm testing it on mandriva, debian and gentoo...
                >
                regards
                nichu
                3 seconds does not necessarily mean 3 real-time seconds. It means at
                least 3 seconds of cpu time - which varies in real life, depending on
                what else is going on in the system.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Gordon Burditt

                  #9
                  Re: apache +php +time limits

                  >generally limit works but it doesn't last for time specified in php.ini
                  >and it lasts ... well rather quite randomly ...
                  As I understand it, the execution time limit is in CPU seconds, not
                  wall clock seconds, and only for the PHP process. So if your script
                  is doing a lot of stuff that doesn't occupy much CPU (*in PHP*),
                  such as disk I/O, network I/O, DNS lookups, or database calls, it
                  may last quite a bit longer.
                  >when I set the limit to lower value (3 seconds) firstly it stopped
                  >script after 7 seconds, 2nd time after ~12 seconds, 3rd time ~9 seconds
                  >and later it last really long (after 25 seconds I stopped it manually)
                  >
                  >probably it has something common with caching but generally sometimes it
                  >lets script working for really long time (much longer than limit in
                  >php.ini stands for)

                  Comment

                  • FutureShock

                    #10
                    Re: apache +php +time limits

                    Michael Vilain wrote:
                    In article <adv8i4l161avmr mcicl0lsj04pqg3 ir6c0@4ax.com>,
                    nadia <nospam@example .comwrote:
                    >
                    >On Tue, 18 Nov 2008 07:29:48 -0500, Jerry Stuckle <jstucklex@attg lobal.net>
                    >wrote:
                    >>
                    >>3 seconds does not necessarily mean 3 real-time seconds. It means at
                    >>least 3 seconds of cpu time - which varies in real life, depending on
                    >>what else is going on in the system.
                    >Really?
                    >Can you tell me where that is documented lease?
                    >(I've never heard of a timer using the CPU before)
                    >>
                    >nadia.
                    >
                    You didn't look very far:
                    >

                    >
                    Pull up that page and search for 'CPU', it's there for sure. Thanks for
                    a lil bit of knowledge ill need down the road.

                    Comment

                    Working...