r/PHPhelp • u/PIAESB • Sep 03 '26
Run a PHP function/Task in the background
I have a WIndows Server running IIS that hosts a primarily PHP based website. It has multiple functions and features but i would like to have atleast one of them running in the background So the user does not have to wait for the task to finish.
Any ideas? fastcgi_finish_request() seems to be Linux only as far as i can tell.
2
Upvotes
View all comments
1
u/Professional-Rule-58 Sep 20 '26
For the 30-second wait you mentioned, I'd store a pending job with a
run_aftertimestamp instead of keeping the web request open withsleep(30).The flow could be:
On Windows, Task Scheduler can launch the worker, although running it once a minute means the delay won't be exactly 30 seconds. A continuously running worker gives you finer timing.
Also,
fastcgi_finish_request()is a PHP-FPM feature, so IIS using FastCGI doesn't automatically provide it.Does Intune reliably have the information after 30 seconds, or would the job need retries? That would affect how I'd handle the waiting.