Answer the question
In order to leave comments, you need to log in
Why is PHP exec() so slow?
I noticed a long time ago that any resource-intensive operations performed through the PHP exec() function take many times, and sometimes an order of magnitude more time than a call from the console.
For example, image-magic's convert works ten times slower than a call from the console.
Has anyone come across? How to bypass it? Push calls from PHP through a queuing system? What options exist? And most importantly, why is this happening?
Answer the question
In order to leave comments, you need to log in
has this method been tested?
<?
`echo hello > ~/hello`
?>
I use it, no problem. I don't know the exact differences from shell_exec, exec, system.
Mm. And try shell_exec() in this way:
Script some_script.sh to teach how to set up semaphores, and then somehow query the execution status of the script via AJAX.
$e = "/usr/bin/nohup /home/work/some_script.sh > /dev/null 2>&1 &";
shell_exec("$e");
Try this way:
$cmd = 'git log';
$result = null;
$process = proc_open($cmd, [1 => ['pipe', 'w']], $pipes, null, null, array('suppress_errors' => true));
if (\is_resource($process)) {
$result = stream_get_contents($pipes[1]);
fclose($pipes[1]);
proc_close($process);
}
var_dump($result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question