Possible Duplicate:
php execute a background process
how can I achieve a task that should be done in thread in php
I have this PHP script that takes a little long to process. However I don't want the viewer to wait for the script to finish. I want him to be able to continue browsing and/or close the browser. Yet I want the script to continue to work... How can I do this? Is there way to create some sort of thread that will allow such a thing?
p.s. I really don't want to re-write the script in another language and execute it via os.
If you can run your script from the CLI, you can "fork" it into a background process from the script your web server is serving by calling something like:
exec('php your_script.php > /dev/null &');
This will allow the page to finish loading, but keep your_script.php running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With