I just moved a site from one site to another. The server environment is very similar (LAMP stack), and all the code worked when it was passed, except for one line. I changed it a bit for testing and still get very strange results:
<?php $out = `php ../test/test.php 123 abc`; ?>
When running php ../test/test.php 123 abc from the command line in SSH, it works fine, as expected. And when I run: php testrunner.php (a file that has only the line "$ out" above in it) in SSH, it also works as expected.
But as soon as I load testrunner.php from the browser, it just freezes. Using ps aux | grep php ps aux | grep php for tracking processes, processes seem to appear and die (shortened for brevity):
myuser 12790 0.0 0.3 259016 45284 . . . 0:00 php ../test/test.php 123 abc
If I change the line "$ out" as follows:
<?php $out = `php ../test/test.php 123 abc &`; ?>
then I invoke the script to run in the background. Surprisingly, after a few seconds, when I started ps aux | grep php again ps aux | grep php ps aux | grep php , it shows the same stuff, but with a new PID. I keep running ps aux and keep seeing it with a different PID. This goes on for quite some time (a few seconds, maybe even a minute).
This is very strange for me, since test.php only has an echo code string for testing.
Works great with the terminal. Hanging and has other strange behavior when calling from the Internet. Did I miss something?
(I have evidence by redirecting the output to a log file, which when launched from a PHP web browser, the script seems to call ITSELF instead of another script, test.php. And when it behaves like this, it does not receive any $argv options .. .but when I run it from the command line, everything is fine! Strange?)
UPDATE: Geez ... I just looked at the server processes, and PHP from test.php started to get out of control. They multiplied by hundreds, or maybe thousands, of processes: the server was down for a minute, SSH and all that. It is now, but I canβt explain what is happening. There are no loops in the code, and both linked files are super simple, isolated for testing purposes ...
I work with my host when they respond to my support ticket to find out if this is related to the environment or what ... what could lead to this happening just by changing the server environment?