So I have found a number of tutorials/guides for running a php script as a background process, but no matter which code I use, the process still appears visible in the browser.
What I am doing is triggering a script that may take 5-10 seconds to run (relies on a third party API). I put the trigger at the very bottom of the page so that the page appears to render completely, but I have noticed that the browser status bar still shows the page as loading until the script runs. Additionally, Firebug is showing one (random?) image as loading until the php script is completely finished running. I can view the script in top
and it is running as a separate process. How can I get the browser to stop waiting for it to finish though?
The code I'm using currently is:
shell_exec('sleep 30 >/dev/null 2>/dev/null &');
I've also tried using exec() but there wasn't any difference.
Disclaimer: My final code will use /usr/bin/GET
, sleep is just to be obvious about what's going on.