Q:

php executing shell command gives random output in only in heavy use mode

Please help me with this issue that I am facing on production server. I launched an application that saves images in a directory only after checking that it does not already exist. 
To check if it already exists I used the following command
find $filePath -name $fileInitial*
I am pretty surprised to see that it all went fine on development and QA but in real environment, out of 50 cases, in 5 cases it returns blank even if the file exists.
I tried replacing backtick operator with exec, shell_exec, passthru, and system. I even tried replacing the find command with ls but still no gain.
Please suggest what can be done?

A:

Depending on your code, I would strongly suggest avoiding exec/shell_exec as much as possible. 
It causes a very large security risk to your whole system if not coded with security in mind.
Not sure why you are having issues with the actual command you are trying to process, however my suggestion would be to use the file_exists() or glob() functions in php instead of going to the file system manually.

