sniperscope Posted May 21, 2009 Share Posted May 21, 2009 Hi gurus. I want to ask you that if start a job with php and (assume that i have 50000 records and delete or move or doing some jobs with that records) and seems it going to take long time. So is php still keep working in background after i click the submit button and then close the browser or navigate other page ??? Hopefully i could explain. Regards Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/ Share on other sites More sharing options...
trq Posted May 21, 2009 Share Posted May 21, 2009 If php isn't attempting to send data back to the client, it would quit, otherwise however it may continue untill the server times out. There really isn't any hard guarantee though. To many variables can come into play. You might take a look at ignore_user_abort but you might also ask yourself is php really what I'm looking for? What exactly are you attempting to do? Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838871 Share on other sites More sharing options...
ToonMariner Posted May 21, 2009 Share Posted May 21, 2009 yep. fork your script. this will be of use: http://uk.php.net/manual/en/ref.exec.php Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838876 Share on other sites More sharing options...
sniperscope Posted May 21, 2009 Author Share Posted May 21, 2009 i am very glad to rapid response. Her is my problem ; i have mailing list which contains over than 400 records. So i send mail magazine through SMTP server and takes long time to finish because i have to keep 3 seconds between each loop (sleep(3)) because of my server thinks that i am spamming. Anyway, after i click to send button my browser wait until php finishes it jobs(which means reach to end of records) so what if i close browser or click another link. Is php stop the working ? My compose page is Compose.php and after composing mail Send.php is getting whole records put them into a loop send mail every records. Did i make you confuse ? Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838879 Share on other sites More sharing options...
JonnoTheDev Posted May 21, 2009 Share Posted May 21, 2009 Execute a background process as ToonMariner has stated. You would never wait for that to complete in a web browser! Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838881 Share on other sites More sharing options...
ToonMariner Posted May 21, 2009 Share Posted May 21, 2009 there used to be a tutorial on phpfreaks on exactly this problem - appears to have disappeared since the refresh... Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838888 Share on other sites More sharing options...
JonnoTheDev Posted May 21, 2009 Share Posted May 21, 2009 example: // start script as background process exec("php /path/to/file.php > /dev/null &"); Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838889 Share on other sites More sharing options...
sniperscope Posted May 21, 2009 Author Share Posted May 21, 2009 example: // start script as background process exec("php /path/to/file.php > /dev/null &"); Ok... What if i use ignore_user_abort(1); set_time_limit(0); I think this way will keep working even if i close browser or navigate another page. So is set time to 0 php will never timeout until my loop finish. Isn't this much easier way ? Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838898 Share on other sites More sharing options...
JonnoTheDev Posted May 21, 2009 Share Posted May 21, 2009 no! Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838901 Share on other sites More sharing options...
sniperscope Posted May 21, 2009 Author Share Posted May 21, 2009 no! Then means should i follow reply #6 or reply #2 ? Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838902 Share on other sites More sharing options...
trq Posted May 21, 2009 Share Posted May 21, 2009 no! Then means should i follow reply #6 or reply #2 ? i think you should read reply #2 again. Its full of if's and maybe's which was my intention. Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-838908 Share on other sites More sharing options...
sniperscope Posted May 22, 2009 Author Share Posted May 22, 2009 Ok.. i read ToonMariner 's link and seems it is far from solution of my problem. Because they are discussing running command on IIS or running windows commands. Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-839538 Share on other sites More sharing options...
ToonMariner Posted May 22, 2009 Share Posted May 22, 2009 don't worry about running on OS... this submission was based on linux servers http://uk.php.net/manual/en/function.exec.php#88704 the principle is exactly the same - all you need do now is formulate the command you need to run your email and pass the relevant arguments. Go step by step and make sure you can run exec on your box as a test then start investigating the path to the script you need to execute - use a test script that just sends you an email that way you won't annoy anyone if you break it. Quote Link to comment https://forums.phpfreaks.com/topic/159069-closing-browser/#findComment-839861 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.