So I am building an application that requires an import and manipulate of a large CSV file. I figure it would be best to let a PYTHON script handle that and have PHP execute the python script.
I would like to accomplish a few things.
Run this process in the backgroup
Monitor this process via ajax.
The issue I am running into is that the script take a while to complete, and the only way i can monitor the process is by capturing the PID, but i dont believe it is being return until the script is complete.
Now when i run a 'quick' script. everythng works great.
Here is my sample code...I am using codeigniter.
$command = 'python /to/my/script.py arg1 arg 2';
$pid = $this->run_in_background($command);
echo(" . ");
function run_in_background($Command, $Priority = 0)
$PID = shell_exec("nohup nice -n $Priority $Command 2> /dev/null & echo $!");
$PID = shell_exec("nohup $Command 2> /dev/null & echo $!");
exec("ps $PID", $ProcessState);
return(count($ProcessState) >= 2);