Long process in php, run it in the background

0

I have a process in PHP that generates an excel file with data calculated from several sql server tables. The problem is that being a process that takes a long time (it may take more than 10 minutes), the server always returns an error "Fatal error: Maximum execution time of 0 seconds exceeded in ..."

I think the best thing for this case would be to create a process that generates the Excel file in the background, and that could report its status. I read something about Gearman, but I do not know how it is implanted.

    
asked by osbragon 08.05.2017 в 14:21
source

1 answer

1

Regardless of how you resolve this situation you need to adjust the time limit so that you do not generate the error Maximum execution time of XX seconds exceeded ...

On the other hand, you can always execute your script on the command line and send it to the background: exec("php -f mi_script.php > /dev/null &"); and then write in the database the progress of it as it is executed. In the frontend then you can have a timeout in JS that check every X time the progress of your script and report the result to your browser.

    
answered by 08.05.2017 / 21:00
source