1

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.

1
  • what version of php are you running? the set_time_limit is not working when safe_mode is on but safe_mode has been deprecated in 5.3 and removed in 5.4. Try to use die() instead of exit() Commented May 4, 2013 at 8:42

2 Answers 2

1

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

max_execution_time = 7200

search in php.ini

Sign up to request clarification or add additional context in comments.

1 Comment

But I want the max execution time variable to be changed when running the script (php script.php 60) = running the script for 60 seconds.
1

What about using set_time_limit function? You can check documentation here

function

void set_time_limit ( int $seconds )

1 Comment

As I said, already tried, looks like it didn't manage to terminate the process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.