Shell_Exec (): How to keep process active when restarting apache?

2

The processes run by php's shell_exec () end up restarting apache. Is it possible to keep processes running uninterrupted when restarting apache?

Below the code I'm using:

$Command = "ksh -c '(  trap \"\" 1 2 3 4 15; ";
$Command .= "./sc_serv /caminho-do-conf/sc_serv.conf";
$Command .= " > /dev/null )' & echo $!"." ;";

$ExecCommand = $Command;

echo "Comando Executado: " . $ExecCommand ;

$Result = shell_exec($ExecCommand);
echo "<pre>$Result</pre>";
    
asked by anonymous 31.08.2014 / 19:25

2 answers

1

I believe there is no way, as the Apache user initiated the process.

Run an exec shell with another non-apache user.

link see this lib that can solve your problem.

    
31.08.2014 / 20:17
0

An elegant solution would be to use the nohup command on Linux.

With this command you can leave a process running in the background and it does not die when you exit. It works great for ssh sessions, and should work for you too.

    
11.09.2014 / 13:39