Search code examples
phpscheduled-tasksschedulerbackground-task

How to run a background task in PHP web application?


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 ?


Solution

  • 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.