user2298995
user2298995

Reputation: 2173

How to limit execution time on a php script

I'm running a php script via Linux (not via my browser) (php script.php). Now, I want to limit the execution time to let's say 10 seconds, which means that after 10 seconds the process will shutdown by itself. How can I do that? Already tried set_time_limit. Already tried sleep(10); exit();

None of them made the script to shutdown.

Upvotes: 1

Views: 793

Answers (2)

Fabio
Fabio

Reputation: 23510

What about using set_time_limit function? You can check documentation here

function

void set_time_limit ( int $seconds )

Upvotes: 1

Rajendra Yadav
Rajendra Yadav

Reputation: 635

Change the maximum execution time (in seconds) in php.ini configuration file.

max_execution_time = 7200

search in php.ini

Upvotes: 1

Related Questions