Is there a way to “background” a long operation; ie return a response to the user while leaving it running?
I have an (infrequently used) operation that needs to be launched from a web request that can take several hours, and I’d like it to not crash when the browser or Apache get tired of waiting for a response.
This is a pretty common question. I'm guessing that the archives have
lots of different, good answers.
You can always spawn a thread or fork the process. Make sure the
initial request is responded to immediately, and then use AJAX to
contact the server looking for updates. Back before AJAX was popular,
I use to just set a META tag telling the status page to reload every
30 seconds. That worked too. You just need to a way for the worker
thread or process to notify the Web server thread of its state.
That's a typical computer science problem.
Happy Hacking!
-jj
--
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/