d.shankar Posted May 26, 2009 Share Posted May 26, 2009 Hi phpfreaks ! This thread may sound a bit crazy but plz to try to help me if you people can. Consider i have a website(www.test.com) and i have a big file with lot of operations in a file called test.php plz assume the file has some 2000 lines of code and at the end of the line there is a insert table operation to make sure that the file has reached the end and all the operatiions above have completed, i.e to make sure if the page was accessed. When a user requests the file from the browser say www.test.com/test.php , the file runs for some 10 seconds to complete the operation. Killer Situation: So when a user closes the window within 10 seconds , the operations won't get completed , the insert operation does not perform too. My request is that when the user closes the window within 10 secs, is it possible to make the file run in the server background so that it gets executed fully or are there any means to perform this ??? Please let me know if this sounds weird !!! Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/ Share on other sites More sharing options...
GingerRobot Posted May 26, 2009 Share Posted May 26, 2009 ignore_user_abort ? Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-842492 Share on other sites More sharing options...
d.shankar Posted May 26, 2009 Author Share Posted May 26, 2009 GingerRobot , thats so impressive .. I'll check and be back to let you know Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-842493 Share on other sites More sharing options...
d.shankar Posted May 26, 2009 Author Share Posted May 26, 2009 Dude it didnt workout for me I requested the page and immediately unplugged my lan cable to check this. But it didnt seem to work.... what may be the problem ? Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-842540 Share on other sites More sharing options...
d.shankar Posted May 26, 2009 Author Share Posted May 26, 2009 I tried like this <?php ini_set("ignore_user_abort", 1); sleep(20); $to = "[email protected]"; $from = '[email protected]'; $subjectx = "testing"; $body="Mail sent"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= $from ."\r\n"; mail($to,$subjectx,$body,$headers); ?> wheni run this file for 20 seconds.. i get the mail. I called this file and immediately closed my browser in 2 seconds but i didnt get the mail any suggestions ?? Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-842559 Share on other sites More sharing options...
d.shankar Posted May 27, 2009 Author Share Posted May 27, 2009 any help would be appreciated. thanks Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-843210 Share on other sites More sharing options...
gevans Posted May 27, 2009 Share Posted May 27, 2009 Why not access it via an ajax request. This would continue it running in the background regardless of what the user does. Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-843219 Share on other sites More sharing options...
d.shankar Posted May 27, 2009 Author Share Posted May 27, 2009 i am not so familiar with AJAX gevans. thanks for the info why the code of mine doesnt work ? Am i playing it right ? Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-843220 Share on other sites More sharing options...
Daniel0 Posted May 27, 2009 Share Posted May 27, 2009 Try ignore_user_abort(true); set_time_limit(0); instead. Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-843223 Share on other sites More sharing options...
d.shankar Posted May 27, 2009 Author Share Posted May 27, 2009 I have tried that too Daniel0, it is supposed to execute the file endlessly. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/159725-how-to-execute-the-file-completely/#findComment-843226 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.