Cannot run background process on Amazon Linux Instance, but runs on MAC OS X
Hello All,
Kindly review this situation. I cannot run a background process in Amazon Linux instance, but The same runs on Mac OS X Following is what happens [root@someIp somePath]# php /path/to/myPhpScript.php arg1 arg2 arg3 > /dev/null 2>log.txt & [1] 17849 [root@someIp somePath]# jobs [1]+ Stopped php /path/to/myPhpScript.php arg1 arg2 arg3 > /dev/null 2>log.txt [root@someIp somePath]# bg 1 [1]+ php /path/to/myPhpScript.php arg1 arg2 arg3 > /dev/null 2>log.txt & [1]+ Stopped php /path/to/myPhpScript.php arg1 arg2 arg3 > /dev/null 2>log.txt [root@someIp somePath]# -------------------- But if I run without & it completes fine. [root@someIp somePath]# php /path/to/myPhpScript.php arg1 arg2 arg3 Prints some output... Prints some output... Prints some output... Prints some output... Done... [root@someIp somePath]# -------- Any Help/suggestions will be of great help. Thank You. |
I figured it out myself.
For some reason, It is being stopped becos it thinks it requires some kind of input from the keyboard. As: 0 : Standard Input (Generally the Keyboard) 1 : Standard Output (Generally the Monitor) 2 : Standard Error So I added the standard input to read from /dev/null. I modified my cmd as follows: [root@someIp somePath]# php /path/to/myPhpScript.php arg1 arg2 arg3 0</dev/null 1 >/dev/null 2>log.txt & OR [root@someIp somePath]# php /path/to/myPhpScript.php arg1 arg2 arg3 </dev/null >/dev/null 2>log.txt & Thanks! :) |
All times are GMT -5. The time now is 02:18 PM. |