LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-24-2011, 11:01 PM   #1
metalhawk
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
Unhappy 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.
 
Old 09-24-2011, 11:30 PM   #2
metalhawk
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How would you run a process in the background? turbomen Linux - Newbie 1 11-16-2010 02:43 AM
How to run a process in Background? anandv_1234 Linux - Newbie 3 02-22-2008 11:47 AM
how to run a process in the X background sh4d0w13 Linux - General 6 09-12-2005 02:54 PM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 12:27 AM
run process in background using system calls indian Programming 2 08-10-2004 05:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration