From the last link: "Note that you should never attempt to use these
process control forking functions when using a webserver; you should
only fork applications when using the PHP command line client."
I guess that kind of answers my question. exec() might actually be the
only solution, I'm not sure - it just seems somewhat untidy. I would
have to log any failures as I go along, I guess.
As an explanation of what I'm doing...
I have a cache. If an item in the cache is more than a week old, I want
to re-fetch the item. I could schedule a job to check for all week-old
objects and re-fetch them, but I think it would be more efficient to
only run the re-fetch if someone loads the cached item and it's more
than a week old (it's ok if web user gets the old item on that
occurance). I don't want to make the user wait for fetching the cached
item. I'd like to hand it off to another script that fetches it in the
background, and doesn't tie up the user with the operation.
I hope that clarifies what I'm trying to do. Perhaps exec() is my only
option.
- Brian
Hans C. Kaspersetz wrote:
Brian Dailey wrote:
Hey guys, my google-fu is failing me today so I thought I would turn
to the brilliant minds of the NYPHP.
What I'd like to do is be able to execute a php script in the
background that does NOT impact the load time of the page itself.
Something that runs in the background and doesn't tie up the web
server. Does that make sense? Do any of you have any idea how one
would accomplish this?
Fork off a php process and let it run separately. I think Synder, Hans
Z and Hendry were doing this for a app a couple of years ago with some
success. When the forked process is done it calls the original script
and reports. But you have to be conscious of garbage processes.
http://us3.php.net/manual/en/function.pcntl-fork.php
http://us3.php.net/pcntl
http://www.electrictoolbox.com/article/php/process-forking/
Hans K
New Jersey Web Design
http://www.cyberxdesigns.com
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php