Start php script in background

0

I have the submit.php file and need it to run in the background while my application is being used by users. The submit.php file instantiates a pool of threads that make specific submissions from my system to the world. I believe that OS (Linux / FreeBSD) or even Apache have this kind of support already implemented.

    
asked by anonymous 10.03.2016 / 15:43

2 answers

2

I had a need very much like yours. It needed to perform a task in the background, return the screen to the user, while the task updated a table in the database with the progress of the process. Explaining the solution a little:

<?php 
exec("/usr/bin/php file.php > /dev/null &");
?>

Where & at the end it runs in the background and "/ dev / null" plays any return on "nothing", not holding the request while the script runs.

I hope I have helped

    
10.03.2016 / 19:30
1

I think the solution you're looking for is a scheduled task (Cron Jobs), read more about how to use here

I hope it helps.

    
10.03.2016 / 18:37