- I hope my explanation is clear - I have a PHP script that takes a long time to execute, so I decided to run it in the background, what happens is that even in the file that I run the second script, wait until finish this execution to answer. Is there any way to make this not happen?
File 1 in this run the 2 script.
$param1 = escapeshellcmd($idProduct);
$param2 = escapeshellcmd($_POST["portales"]);
$param3 = escapeshellcmd($_SESSION["username"]);
exec("php -f C:\wamp64\www\ruta-del-fichero\test.php $param1 $param2 $param3 > salida.txt");
File 2 is the one that is executed from file 1.
<?php
include "CreateProductPortals.php";
require "conex.php";
$db = new SqlConexionCreations();
$portales = explode(",", $_SERVER['argv'][2]);
$usuario = $_SERVER['argv'][3];
$result = new CreateProductPortals($portales, $db, $_SERVER['argv'][1], $usuario);
$resultado = (is_array($result) || is_object($result)) ? json_encode($result):$result;
$query = "INSERT INTO [logs_creaciones] (usuario, resultado) VALUES ('{$usuario}', '{$resultado}')";
die(var_dump($db->query($query)));