-d max_execution_time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alvaro G Vicario

    #1

    -d max_execution_time

    I'm writing a shell script under Red Hat 9 that will process some thousand
    records from a database so it'll normally take several minutes. According
    to manual I can override the max_execution_t ime directive using the -d
    switch. However, that switch seems to be ignored:

    #!/usr/bin/php -d max_execution_t ime=1 -q

    <?
    ........
    ?>

    No matter what value I write (0, 1, 9999...) the script stops after 30
    seconds:

    Maximum execution time of 30 seconds exceeded

    The scripts runs as root and PHP is not using safe mode. I'm probably
    missing something but I can't figure out what it is. Thank you in advance
    for any clue,

    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --
  • Kevin Thorpe

    #2
    Re: -d max_execution_t ime

    Alvaro G Vicario wrote:[color=blue]
    > I'm writing a shell script under Red Hat 9 that will process some thousand
    > records from a database so it'll normally take several minutes. According
    > to manual I can override the max_execution_t ime directive using the -d
    > switch. However, that switch seems to be ignored:
    >
    > #!/usr/bin/php -d max_execution_t ime=1 -q
    >
    > <?
    > .......
    > ?>
    >
    > No matter what value I write (0, 1, 9999...) the script stops after 30
    > seconds:
    >
    > Maximum execution time of 30 seconds exceeded
    >
    > The scripts runs as root and PHP is not using safe mode. I'm probably
    > missing something but I can't figure out what it is. Thank you in advance
    > for any clue,[/color]

    Can't you add set_time_limit( 0) to the php script?

    Comment

    • Pedro Graca

      #3
      Re: -d max_execution_t ime

      Alvaro G Vicario wrote:[color=blue]
      > I'm writing a shell script under Red Hat 9 that will process some thousand
      > records from a database so it'll normally take several minutes. According
      > to manual I can override the max_execution_t ime directive using the -d
      > switch. However, that switch seems to be ignored:
      >
      > #!/usr/bin/php -d max_execution_t ime=1 -q
      >
      ><?
      > .......
      > ?>
      >
      > No matter what value I write (0, 1, 9999...) the script stops after 30
      > seconds:
      >
      > Maximum execution time of 30 seconds exceeded
      >
      > The scripts runs as root and PHP is not using safe mode. I'm probably
      > missing something but I can't figure out what it is. Thank you in advance
      > for any clue,
      >
      > --[/color]

      I guess PHP does not recognize options in the #! line
      try

      #!/usr/bin/php
      <?php
      ini_set('max_ex ecution_time', 0);
      // rest of script
      ?>


      But php should assume max_exexcution_ time = 0 when running from the
      command-line. I tried

      $ php -r '$x = ini_get("max_ex ecution_time"); echo "$x\n";'
      0

      $ php -d max_execution_t ime=456 -r '$x = ini_get("max_ex ecution_time"); echo "$x\n";'
      456

      --
      --= my mail address only accepts =--
      --= Content-Type: text/plain =--

      Comment

      • Alvaro G Vicario

        #4
        Re: -d max_execution_t ime

        *** Pedro Graca wrote/escribió (27 Nov 2003 10:58:36 GMT):[color=blue]
        > I guess PHP does not recognize options in the #! line try
        > ini_set('max_ex ecution_time', 0);[/color]

        You are right, it seems PHP got confused by what you say. And I got
        confused because it certainly does accept the -q switch. Now it works fine.
        [color=blue]
        > But php should assume max_exexcution_ time = 0 when running from the
        > command-line.[/color]

        # php -r '$x = ini_get("max_ex ecution_time"); echo "$x\n";'
        Error in argument 1, char 2: option not found r
        Error in argument 1, char 2: option not found r
        Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}

        I have the PHP packages bundled with Red Hat 9, it must be they are either
        an older version or they are built with different options... :-?

        Thank you for your help,


        --
        --
        -- Álvaro G. Vicario - Burgos, Spain
        --

        Comment

        • Pedro Graca

          #5
          Re: -d max_execution_t ime

          Alvaro G Vicario wrote:[color=blue][color=green]
          >> But php should assume max_exexcution_ time = 0 when running from the
          >> command-line.[/color]
          >
          > # php -r '$x = ini_get("max_ex ecution_time"); echo "$x\n";'
          > Error in argument 1, char 2: option not found r
          > Error in argument 1, char 2: option not found r
          > Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}
          >
          > I have the PHP packages bundled with Red Hat 9, it must be they are either
          > an older version or they are built with different options... :-?[/color]

          I think you're using the CGI SAPI. I can't test that here.

          $ php -v
          PHP 4.3.3 (cli) (built: Nov 19 2003 23:12:29)
          Copyright (c) 1997-2003 The PHP Group
          Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

          $ php -h
          Usage: php [options] [-f] <file> [args...]
          php [options] -r <code> [args...]
          ....
          -r <code> Run PHP <code> without using script tags <?..?>
          -s Display colour syntax highlighted source.
          -v Version number
          --
          --= my mail address only accepts =--
          --= Content-Type: text/plain =--

          Comment

          • Alvaro G Vicario

            #6
            Re: -d max_execution_t ime

            *** Pedro Graca wrote/escribió (27 Nov 2003 11:40:06 GMT):[color=blue]
            > I think you're using the CGI SAPI. I can't test that here.
            >
            > $ php -v
            > PHP 4.3.3 (cli) (built: Nov 19 2003 23:12:29)
            > Copyright (c) 1997-2003 The PHP Group
            > Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies[/color]

            # php -v
            4.2.2

            [color=blue]
            >
            > $ php -h
            > Usage: php [options] [-f] <file> [args...]
            > php [options] -r <code> [args...]
            > ...
            > -r <code> Run PHP <code> without using script tags <?..?>
            > -s Display colour syntax highlighted source.
            > -v Version number[/color]

            # php -h
            Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}
            -q Quiet-mode. Suppress HTTP Header output.
            -s Display colour syntax highlighted source.
            -w Display source with stripped comments and whitespace.
            -f <file> Parse <file>. Implies `-q'
            -v Version number
            -C Do not chdir to the script's directory
            -c <path> Look for php.ini file in this directory
            -a Run interactively
            -d foo[=bar] Define INI entry foo with value 'bar'
            -e Generate extended information for debugger/profiler
            -z <file> Load Zend extension <file>.
            -l Syntax check only (lint)
            -m Show compiled in modules
            -i PHP information
            -h This help


            The funny thing is that I can't find any "cli" packet in Red Hat
            repositories. Never mind, it works so it's fine :)

            --
            --
            -- Álvaro G. Vicario - Burgos, Spain
            --

            Comment

            • Pedro Graca

              #7
              Re: -d max_execution_t ime

              Alvaro G Vicario wrote:[color=blue]
              > The funny thing is that I can't find any "cli" packet in Red Hat
              > repositories. Never mind, it works so it's fine :)[/color]

              With Debian I did:

              # apt-get install php4-cgi

              Maybe the package name is cgi also on Red-Hat, if you want to install
              it.


              Anyway, glad you have it working
              --
              --= my mail address only accepts =--
              --= Content-Type: text/plain =--

              Comment

              • jeva
                New Member
                • Jun 2006
                • 2

                #8
                try using the set_time_limit( int seconds) function



                Originally posted by Alvaro G Vicario
                I'm writing a shell script under Red Hat 9 that will process some thousand
                records from a database so it'll normally take several minutes. According
                to manual I can override the max_execution_t ime directive using the -d
                switch. However, that switch seems to be ignored:

                #!/usr/bin/php -d max_execution_t ime=1 -q

                <?
                ........
                ?>

                No matter what value I write (0, 1, 9999...) the script stops after 30
                seconds:

                Maximum execution time of 30 seconds exceeded

                The scripts runs as root and PHP is not using safe mode. I'm probably
                missing something but I can't figure out what it is. Thank you in advance
                for any clue,

                --
                --
                -- Álvaro G. Vicario - Burgos, Spain
                --

                Comment

                Working...