I have a long running PHP script that i want to be executed in background on server after a user action. and the user should be redirected to other page while command should be running in background. Below is the code
$command = exec('php -q /mylongrunningscript.php');
header("Location: /main.php?action=welcome");
The above script is running fine, but page does not redirected until $command = exec('php -q /mylongrunningscript.php');
is executed.
I want that user should be immediately redirected to the welcome page.
Is there any other way to achieve this task. The other idea is that that $command = exec('php -q /mylongrunningscript.php'); should be executed on welcome page, but welcome page HTML is shown after the command has executed. command takes about 5,6 minutes and this time page does not redirects.
I am On Cent os Linux with PHP 5.3