PHP: can't get ignore_user_abort(TRUE) working
I have a script that has ignore_user_abort(TRUE); at the top and I call it like this
$socket = curl_init("http://...");
curl_setopt($socket, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($socket, CURLOPT_TIMEOUT_MS, 1000);
$result = curl_exec ($socket);
curl_close($socket);
This script d开发者_开发问答oes some boring work that I want to run in the background and judging from the result the script starts to do that work but shortly after that it stops. I've tried everything I know and I am really stuck now. May be there is some server config that can be blocking ignore_user_abort()? Please let me know if you have any ideas about this.
PS. set_time_limit() is set to a high value and cpanel is catching all errors into the error log so it is not dying of a fatal error.
curl_setopt($socket, CURLOPT_TIMEOUT_MS, 1000);
here you define the maximum number of milliseconds to allow cURL functions to execute as 1000...so you are allowing your curl function to run only for one second....maybe this is it
http://php.net/manual/en/function.curl-setopt.php
1) PHP does not detect connection abort in every time. May be its a bug. 2) If you are working on reseller/shared hosting then you will not be able to change the value for ignore_user_abort, set_time_limit etc.
精彩评论