veilig
veilig

Reputation: 5135

php script test max execution time

2 questions for PHP in Linux:

1.) will register_shutdown_function be called if a script exceeds the maximum time limit for the script to run?

2.) if #1 is true, how can I test a script going beyond its max time limit if sleep() doesn't count towards execution time?

Upvotes: 2

Views: 5355

Answers (1)

phihag
phihag

Reputation: 288100

A function registered with register_shutdown_function will be called when the execution time limit is reached. You can test the limit with a busy wait:

<?php
register_shutdown_function(function() {
    echo "shutdown function called\n";
});

set_time_limit(1); // Set time limit to 1 second (optional)
for (;;) ;         // Busy wait

Upvotes: 8

Related Questions