I writing a PHP script program under Linux. In the script, I need call many other system tools/programs using exec to achieve some goals. I know that whenever I run a shell script in terminals, a new child process will be created and run with the parent. If I use too many exec in my PHP script and there should be many processes running back and forth, I assume that would be inefficient because processes are heavy-weighted.
Here is my question: what are the efficient ways and common patterns to approach programming goal in Linux? Will PHP ideal in such situation?
Even the overhead of using
execis more than just a standard PHP function call, I would not consider it expensive at all. It is a pretty effective way of doing things and when you keep security considerations in mind, I’d say there is nothing wrong with it.You might ask if pre-mature optimization is worth the trouble? I’d say no then.