Max Execution time-Image1

How to Increase Your PHP Maximum Execution Time

You are here:
Estimated reading time: 2 min

An important aspect to remember about PHP programs is that the maximum time to execute a script is normally set to thirty seconds, although the time limit varies from one hosting company to another. Programs that involve sending mail to many recipients or some heavy export or import of files can cause the user to get errors if the maximum time limit exceeds.

You might need to increase the limit for certain scripts your website uses. For instance, migration plugins in WordPress, depending on how big your website is, usually require a longer run time.

Thirty seconds is the default setting, and you can increase that value. Keep in mind that the value is in seconds, so 2 minutes would be 120, 3 minutes would be 180, and so on. To find the correct value, you can check your plugin, script, or theme documentation. You can use the phpinfo() function to verify the current value of the max_execution_time directive and other directives.

If you’re wondering how to set PHP maximum execution time on cPanel, we’re going to do a quick step-by-step guideline for new learners that want to do this. The first thing you need to do once you log in to your cPanel account using your username and password or you can also log in via G Online Sites Client Area.

The next thing you want to do is find the PHP Selector button. After you’ve selected this button, you will go to the Options section for the php.ini values and scroll down to max_execution_time.

Max Execution time-Image1

 

For Unlimited, you set the value to 0. Once you have done the change, make sure that you do a left-click anywhere outside the text input or dropdown box. If you’ve managed to successfully follow the steps we’ve mentioned above, you will be able to see a green box with a message that will confirm that the change you’ve made has been applied.

Measuring Script Execution Time

The time required to execute the PHP script is the script execution time in PHP. Rather than the CPU execution time, use clock time to calculate script execution time. What will help to know the script execution time is knowing the clock time after script execution and before script execution.

Use the microtime() function at the beginning and the end of the script. Then using the formula (End_time – Start_time). Time returns in seconds with the microtime() function. Execution time depends on the processor, and it is not fixed.

Now you know everything there is to know about increasing the maximum execution time of a script in cPanel. For any further assistance, make sure you contact us so we can help you!

Was this article helpful?
Dislike 0

Author

Joshua

Web Hosting Geek Technical Support Staff G Online Sites