Can anyone tell me why exec()
function is so slow and time unpredictable on different machines in PHP?
Basically I have some executable file and want to execute it through PHP:
$command = '/usr/pathToComman/myCommand -someParameters';
exec($command);
The thing is that it executes much longer (by much I mean 3-4 sometimes like 25 times longer) then the same command from the shell.
In additional to this the command is executed longer from the PHP on my server, which is stronger (more RAM and more GHz).
So there are two questions:
P.S. I need this execute, because I can not do the same thing with PHP
P.S.2 Answering @prodigitalson question: It solves the differential equation, but basically no matter what it does, the speed is just much slower. I remember doing some image processing this way and the speed was also much slower.
The problem why this is slower is probably because your PHP server has to go to the shell to run your command. So what the PHP server does then is create a new shell and call the command on the new shell. Creating a new shell means in most systems to create a new thread. So all those things together result in a longer execution time.
Sometimes a cgi script can help with those problems, but I'm not sure if it will help here (because I don't really know what you are trying to do on the shell)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With