I am creating a small plugin get get’s data from different websites. The data does not have to be up to date, and I do not want to use a cronjob for this.
Instead with every visit of the website I want to check if the DB needs updating. Now it takes a while before the whole db is updated, and I do not want the user waiting for that.
Is there a way that I can have the function fired, but in the background. The user will just work as normal, but in the background the db is updating.
You could also fork the process using pcntl_fork
As you can see in the php.net example you get two execution threads following the function call. The parent thread could complete as usual, while the child could go on doing its thing