Set Max_Execution_Time in PHP Cli

Set max_execution_time in PHP CLI

The documentation says that when running in command line mode, the default is 0 (unlimited). It doesn't say that you cannot override it:

set_time_limit(10); // this way
ini_set('max_execution_time', 10); // or this way

Edit: I just tried it myself, and it works as expected.

F:\dev\www>c:php -f index.php
PHP Fatal error: Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3

Fatal error: Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3

How to increase maximum execution time in php

ini_set('max_execution_time', '300'); //300 seconds = 5 minutes
ini_set('max_execution_time', '0'); // for infinite time of execution

Place this at the top of your PHP script and let your script loose!

Taken from Increase PHP Script Execution Time Limit Using ini_set()

How to get PHP max_execution_time from the command line?

PHP cli by default not have max_execution_time limit

You can get by running:

php -i | grep max_execution_time

make script execution to unlimited

You'll have to set it to zero. Zero means the script can run forever. Add the following at the start of your script:

ini_set('max_execution_time', 0);

Refer to the PHP documentation of max_execution_time

Note that:

set_time_limit(0);

will have the same effect.

How can I get infinite maximum execution time with PHP?

When you run it command line there will be no maximum execution time.

You can also use set_time_limit(0); for this if your provider allows manipulation.

I can't tell if your ip-address will get banned - as this depends on the security of the server you send your requests to.


Other solution

You can fetch one (or a few) page(s), and search for new URLs throughout the source code. You can then queue these in a database. Then on the next run, you process the queue.



Related Topics



Leave a reply



Submit