Well basically I may want to execute a script that may take as much as 1 hours as well.
What I really want to do is Send SMS to my users using a third party API. So its basically like I supply my script with an array of phone numbers and fire the method to send SMS.
However assuming it take 5 seconds to send 1 SMS and I want to send 1000 SMS which is roughly 1 - 2 hours. I can't use set_time_limit()
because I am on shared host.
One way to do this is store numbers in a session and execute each SMS and use javascript to refresh that page until end. This way I need to keep my browser open and the execution will stop if my Internet Connection is disconnected.
So, Is there any better way to do this ?
Hope I am clear enough to explain what I want? I want to execute a large script that may take hours to execute without getting timeout.
Remember, the max execution time of a PHP script is 30 seconds.
Executing PHP files ¶ There are three different ways of supplying the CLI SAPI with PHP code to be executed: Tell PHP to execute a certain file. Both ways (whether using the -f switch or not) execute the file my_script.
A PHP script executed from the command-line or from a shell script, cron job, etc. does not have a timeout.
For CLI-invoked scripts, even if you set the PHP script's timeout dynamically with the set_time_limit()
function, it has no effect.
PHP scripts running from the command line aren't affected by max_execution_time
option.
So you don't have to worry at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With