Jump to content

Forking Question


M4verick

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.