如何在PHP Web应用程序中运行后台任务? [重复]

This question already has an answer here:

I want to run a background scheduler in my web application. This scheduler will check the current time and if it matches with the programmed time then it sends a E-mail. How can i create background Scheduler ?

</div>

It depends if you want to run a script in background via command line, than you can use exec command: exec

Or if you want to start another thread, than you can use pthreads

If you want to have a job that executes at a certain time or in certain intervals, you can set up a cronjob. This tutorial is very helpful, and if you are on linux you can look at this documentation.

You need to setup cron job. You may find more information a link!