I run a large number of PHP scripts via CLI executed by CRON in the following format :
/usr/bin/php /var/www/html/a15432/run.php
/usr/bin/php /var/www/html/a29821/run.php
In some instances there is a problem with once of the files whereby the execution of the file enters a loop or simply does not terminate due to an error in that particular script.
What I would like to achieve is that if either of the above occurs, PHP CLI simply stops executing the script.
I have searched this and all indications are that I need to use this command, which I have entered at the beginning of each file, but it does not seem to be making any difference.
ini_set('max_execution_time', 30);
Is there any other way I can better protect my server so that one (or more) of these rogue files cannot be allowed to bring down the server by entering some kind of infinite loop and using all of the servers resources trying to process the file? To make the problem worse, these files can be triggered every 5 minutes which means that at times, there are loads of the same files trying to process.
Of course I realise that the correct solution is to fix the files so that there is better error handling and that they are never allowed to enter this state, but at the moment I'd like to understand why this doesn't work as expected.
Thank you.