My question revolves around the use of curl_multi_exec in PHP. I am using code similar to the example shown on this link: http://www.rustyrazorblade.com/2008/02/curl_multi_exec/
With about 10 URLs to execute, I sometimes come across the error message:
Fatal error: Maximum execution time of 30 seconds exceeded in... This message points to the curl_multi_exec line in the code.
I need to continue processing in spite of this and also use means to keep a note of which URL failed to execute.
Can someone help me handle this situation?
Thanks!
I would try having a parent process which forks out children processes. The parent process is able to wait till the child is done and can see the exit code of the child. So if the url was processed successfully then it would have an exit code of 0, otherwise a nonzero represents an error.
The parent process will still need to have a longer max_execution_time setting which can be set within the script itself, while the children have a max_execution_time setting of 30 seconds.
Here is how to fork with PHP
http://www.electrictoolbox.com/article/php/process-forking/
You can set the parent’s max_execution_time like this
0 will allow the script to run without a time limit.
Just a side note about child processes, a child process must be allowed to finish before killing the parent, otherwise you can have zombie processes with no one owning them.