Scenario
I have a old blog on blogger that contains thousands of images and posts, i have already imported the posts from blogger to wordpress using their import service (which does not import images) now i want to write a php cURL script that will download all the images off my old blogger blog to wordpress.
Problem
I have already written a script that goes through all the posts and find the image links of blogger and download the links recursively and store them local to wordpress installation but the problem is that the script stops if its taking longer than max_execution_time
which is generally set to 30 secs. Now i dont want to change setting in php.ini file.
Is there some way that i can keep my script executing for that long or some other alternative…. like executing in batch or something else…
Reason for not changing php.ini settings is that i want to release this script as opensource plugin for wordpress, and not many have access to their php.ini file on the server and and many don’t like changing settings for just one script that might run just once.
Thank You for helping….
You can modify some ini settings at run time, so they only affect the current incarnation of the script. In this case, there’s a special function, set_time_limit():
This will effectively remove the time limit on your script execution. All other scripts will be unaffected.
If you’re able to call
set_time_limit
for some other, non-zero time, you can reset the time limit each time you iterate, since the timer is reset each time it’s set.Or, better said by the docs :
Just make sure you pick a sufficiently long time for each iteration to complete