[linux] Re: php exec vraag
Rob Sterenborg
rob op sterenborg.info
Ma Jan 15 09:43:44 CET 2007
> Ik wil een commando (shellscript) laten executeren via een
> php-interface. Nu duurt die executie enkele minuten tot enkele
> uren en ik wil de web-interface niet al die tijd laten wachten.
>
> In eerste instantie dacht ik aan
>
> $command="nohup ./script parameters &";
> exec($command);
>
> maar ook dan blijft de interface wachten tot het script is afgelopen.
> Heeft iemand suggesties hiervoor?
Dit is van: http://nl2.php.net/exec.
Volgens mij is dat toch wat je zoekt?
Groet,
Rob
=======
PHP at jyoppDot-com
04-Oct-2006 07:38
Here's a function to launch a low-priority background process very
simply, returning control to the foreground. I found that a lot of the
other approaches shown here allow the script to continue running, and
the page is served up to the user, but the PHP thread that launched the
process cannot be re-used until the process has completed. Stdout and
stderr need to be redirected to /dev/null to prevent this.
This is for BSD/*NIX servers only (tested on Fedora Core and OSX).
Win32 approaches would be necessarily very different. Omit 'nice' if
you don't want to run the process with lowered priority.
<?php
function fork($shellCmd) {
exec("nice $shellCmd > /dev/null 2>&1 &");
}
?>
=======
More information about the Linux
mailing list