|   Mailinglisten-Archive | 
From: "Gloss Mathias" <Mathias.Gloss_(at)_start.de>
> Das Problem hierbei ist, daß man aus PHP raus nicht einfach Subprozesse
> starten kann, die den Tod des Parents überleben. Wir hatten mal was
gemacht,
> wo über PHP ein Programm im Hintergrund gestartet werden sollte, und das
> ging nur, wenn man ein anderes Programm dazwischen geschaltet hatte...
> leider hab ich das Shellscript, das wir gebastelt haben, nicht hier auf
der
> Arbeit,
um die Zeit...?
> aber ich kann mal heute abend danach schauen. Auf jeden Fall gings nicht
> ohne ein vorgeschaltetes Script / Programm.
Danke Mathias, das hier hab ich auch noch gefunden und derjenige schreibt,
dass der Prozess weiterläuft, selbst wenn einer den Browser schließt (steht
im vorletzten Abschnitt):
For those who want to execute a .php script to run in the background, from
a
.php web page...
exec("php script.php parameters 2>dev/null >&- <&-
>/dev/null &");
Where...
- php is the path to your php script executer (php has to be specifically
complied to be to do this)
- script.php is the script
- parameters are none or more parameters
- 2>dev/null redirects the stderr to a file
- <&- switches off the stdin
- >&- switches off the stdout
- >dev/null redirects all other output to the file dev/null
- & direct script to run in background
This is the only way I managed to get it working (Linux & Apache, php
4x enviroment) . What is also great is that the process is forked so even
though a user may close the browser that initiated the exec(), the process
will still run to completion. And the dev/null file can be turned into a
log.
What I found odd is that the script I was execing would run fine in the bg
when executed from the command line, but not from the browser until I
closed the stdin and stdout.
    php::bar PHP Wiki - Listenarchive