M4verick Posted April 29, 2011 Share Posted April 29, 2011 I have a site that executes a shell script that takes a bit of time to run, the information it outputs does need to be displayed in the page. My problem is whenever the script is run, it stalls the entire apache process until the script has run. So every time the script gets run, I'm looking at about 30 - 120 seconds of downtime while that happens. I'd like to fork off the process if possible so that apache can continue to operate, and I think I'm just having issues understanding where I would place and implement the code. A user fills out a form and hits submit, so should I have the form action submit it to a new page with the forking function to process the shell script/etc? And if so, how do I get it to return the results, because doesn't that then mean that the web page would technically just display the page from the form submission, and not the actual script results? For clarification, I'm referring to using the pcntl_fork function, and I did look at it on php.net, I think I'm just a little confused still as how to apply it to my scenario. Looks like if the output wasn't necessary it wouldn't be quite so hard. Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/ Share on other sites More sharing options...
fugix Posted April 29, 2011 Share Posted April 29, 2011 hey maverick..take a look at this topic here Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208323 Share on other sites More sharing options...
M4verick Posted April 29, 2011 Author Share Posted April 29, 2011 Yeah, I've actually read that post shortly after I posted this question. But that method just backgrounds it doesn't it? I don't need it to background, just fork it off and let the user wait it out that 30 to 120 seconds but let apache keep serving for everyone else. Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208325 Share on other sites More sharing options...
fugix Posted April 29, 2011 Share Posted April 29, 2011 Sorry about the first post...i inserted code tags instead of url tags..oops. Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208326 Share on other sites More sharing options...
M4verick Posted April 29, 2011 Author Share Posted April 29, 2011 Sorry about the first post...i inserted code tags instead of url tags..oops. No worries. Does my original question make sense? Or do I need to clarify it better? Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208329 Share on other sites More sharing options...
fugix Posted April 29, 2011 Share Posted April 29, 2011 also, "forking" actually means to send a process to the background...so im not 100% sure what it is that you are trying to accomplish..my appologies Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208330 Share on other sites More sharing options...
M4verick Posted April 29, 2011 Author Share Posted April 29, 2011 Oh, I thought forking was just splitting off a process. So perhaps what I'm asking for isn't even possible. What I'm trying to do, is prevent the apache process from stalling while running a shell script. The only way I could think to do it was by splitting off the process so that when the script is run, the user follow the newly created process while everyone else follows the main process uninterrupted. Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208334 Share on other sites More sharing options...
fugix Posted April 29, 2011 Share Posted April 29, 2011 the method(s) that I posted on the other thread are the only methods that I know of...especially for a shell script...my appologies Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208345 Share on other sites More sharing options...
M4verick Posted April 29, 2011 Author Share Posted April 29, 2011 Well if anyone knows anything, I would greatly appreciate it if they would share the information. The more I'm reading into it, it actually may be an issue with the shell_exec() function and apache, which are beyond my control. I'll keep looking into it and if I find the answer, I'll share it with everyone. Quote Link to comment https://forums.phpfreaks.com/topic/235112-forking-question/#findComment-1208393 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.