Results 1 to 9 of 9
Thread: Help with running bg processes
-
06-02-2005, 08:31 PM #1Web Hosting Master
- Join Date
- Feb 2002
- Posts
- 3,729
Help with running bg processes
Hello,
I have a php script that I run via command line interface(CLI).
I start the script using a command like the following via command line:
Code:php script.php 1 database&
I see the output of the script on my screen. What it does is basically download a certain file every 10 minutes, parse the data in the file and slot it into a database.
Now how would i get out of that screen *without* ending the process? Nothing seems to work.
As soon as i close the shell, the process seems to end. If i try to hit [enter] a couple of times and quickly squeeze in the word "logout", true enough the bash prompt will disappear *but* the screen remains as it is. I assume that bash is waiting for the php script to finish execution. Problem is, it never will.
Could someone please help me out here? I'm in a fix. :/
Thank you.• Have • you • Floble'd • today? •
-
06-02-2005, 08:39 PM #2Web Hosting Master
- Join Date
- Feb 2002
- Posts
- 3,729
By the way, i need to get out of the screen which contains the output of the php script, so that i'm able to either:
1) Get out of the shell alltogether
2) Execute other commands via bash
Currently it doesn't let me do any of the above. I have no choice but to stare at the output of the script.• Have • you • Floble'd • today? •
-
06-02-2005, 08:53 PM #3Web Hosting Evangelist
- Join Date
- Aug 2004
- Location
- Sydney, Australia
- Posts
- 465
nohup command & should work
-
06-02-2005, 08:55 PM #4Web Hosting Master
- Join Date
- Feb 2002
- Posts
- 3,729
I don't understand you Karthick?
Do i open up another shell window? What exactly should i type?• Have • you • Floble'd • today? •
-
06-02-2005, 09:01 PM #5Web Developer
- Join Date
- Feb 2003
- Location
- Connecticut
- Posts
- 5,460
-
06-02-2005, 09:03 PM #6Web Hosting Evangelist
- Join Date
- Aug 2004
- Location
- Sydney, Australia
- Posts
- 465
The & itself should run the process in the background. Example:
Code:yum list > yum.list &
Code:nohup php script.php 1 database &
Code:php script.php 1 database > somefile &
-
06-02-2005, 09:04 PM #7Web Hosting Master
- Join Date
- Feb 2002
- Posts
- 3,729
Thank you.
I used that command and it seems to work.
What do i do if i want to resume the viewing of the script's output?• Have • you • Floble'd • today? •
-
06-02-2005, 09:07 PM #8Web Hosting Evangelist
- Join Date
- Aug 2004
- Location
- Sydney, Australia
- Posts
- 465
If you used nohup, then
Code:cat nohup.out
Code:tail nohup.out
Code:cat somefile
Code:tail somefile
-
06-02-2005, 09:37 PM #9Web Hosting Master
- Join Date
- Feb 2002
- Posts
- 3,729
This seems to work.
Thank you very much folks, I appreciate the assistance. =)• Have • you • Floble'd • today? •