| Welcome to WebmasterWorld Guest from 188.8.131.52 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Triggering php scripts in background|
by curl, exec, cron jobs
| 6:28 pm on Jan 17, 2011 (gmt 0)|
I need to trigger a php script to run every 1-2 seconds (an email sender).
Because including it in my page footer would cause some delay visible to users, I want to trigger it in background, I was thinking to trigger an EXEC from page footer by PHP like this:
but is the same because curl waits for the script to run, maybe curl has an option that just triggers this without waiting for the output?
| 6:39 pm on Jan 17, 2011 (gmt 0)|
You could include it in your footer:
Would have no noticable delay to the end user.
| 6:52 pm on Jan 17, 2011 (gmt 0)|
I didn't knew that, so the ob_flush() will finish the output that is sent to user and continue the rest in background?
| 7:14 pm on Jan 17, 2011 (gmt 0)|
I made a quick test like this:
If the of_flush does what I thought, I would expect it to load page instantly but it does wait the 5 seconds before showing the text.
| 12:49 pm on Jan 18, 2011 (gmt 0)|
Hmm. That's a bit odd. Try witbh just flush() rather than ob_flush() then.
Or, it could just be sleep() alters behaviour and is not an accurate representation of a slow script running.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved