Re: Startinga shell process with a life of its own
| From: | Richard Lynch | Date: | Fri, 07 Jul 2006 20:41:06 +0000 |
| Subject: | Re: Startinga shell process with a life of its own | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-239201@lists.php.net to get a copy of this message | ||
On Thu, July 6, 2006 9:29 pm, John Gunther wrote:
> Which PHP method allows me to start a shell process from a web page
> script and let it proceed to its conclusion even though I end the
> page.
> Most of the various execute functions seem to wait for the process to
> finish before PHP continues. I don't understand the ones with
> open/close
> functions. Will opening a process and failing to close it let it run
> after the page ends? Will failing to close cause other problems? Can
> you
> point me to example code? The shell commands I want to run are
> typically
> themselves PHP programs whose execution time is far too long to
> complete
> in a browser context.
On some machines, on some OSes, in some configurations, with some
commands, tacking "&" onto the end of what you exec, will sometimes
"work"...
I would recommend, however, that you re-structure things slightly so
that the Architecture is more like this:
User visits web page.
Page generates a database record of what needs to be done.
Page finished.
CRON JOB:
Look in task list of what needs doing, and do some of them.
Make sure only one job is done at a time, or whatever race conditions
are handled here.
I've done projects both ways, and always end up frustrated with the
"PHP attempts to background a process" and the "Task List + Cron"
always works out far far better.
--
Like Music?
http://l-i-e.com/artists.htm