Zunächst einmal Windows verwenden.PHP Exec-Funktion funktioniert nicht gut
Ich habe den folgenden Code:
index.php
<?php
error_reporting(E_ALL);
$tiempo_inicio = microtime(true);
exec('C:\wamp\bin\php\php5.5.12\php.exe -e C:\wamp\www\mail.php > /dev/null &');
$tiempo_fin = microtime(true);
echo ($tiempo_fin - $tiempo_inicio);
?>
Mail.php
<?php
$tiempo_inicio = microtime(true);
$logs = fopen("test.txt","a+");
sleep(2);
$tiempo_fin = microtime(true);
fwrite($logs, ($tiempo_fin - $tiempo_inicio)."
");
sleep(4);
$tiempo_fin = microtime(true);
fwrite($logs, ($tiempo_fin - $tiempo_inicio)."
");
sleep(6);
$tiempo_fin = microtime(true);
fwrite($logs, ($tiempo_fin - $tiempo_inicio)."
");
echo 'fin';
?>
Aber es funktioniert nicht wie ich hoffe, weil das, was ich will Lauf ist Die Datei im Hintergrund ohne den Benutzer wartet auf die Fertigstellung dieser Datei.
Was mache ich falsch?
Ich denke & Prozess im Hintergrund zu laufen Linux ist. Obwohl ich kein Windows-Benutzer bin, denke ich aber, dass Sie hier falsch liegen. Eine bessere Methode wäre es auch, '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 'an. Wenn der Hintergrundjob schwer ist, ist die Wahrscheinlichkeit eines Serverabsturzes geringer – georoot