Results 1 to 7 of 7
If i have a background process and i want to move it at foreground, what must i do? I try with fg <proc> but i did nothing
Also the nohup ...
- 06-11-2011 #1Just Joined!
- Join Date
- Apr 2011
- Posts
- 9
Background process
If i have a background process and i want to move it at foreground, what must i do? I try with fg <proc> but i did nothing
Also the nohup command simply dont send the exit signal at a back process. RIGHT?
- 06-11-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
Type "jobs" to get a list of jobs in the background of that terminal, e.g.:
[1] Running ./job1.sh &
[2] Running ./job2.sh &
Then bring to the foreground the job you want, based upon its job numer, e.g.
If you want better control of this kind of thing, i'd recommend using the screen program.Code:fg 1
- 06-12-2011 #3Just Joined!
- Join Date
- Dec 2009
- Location
- California
- Posts
- 69
As the other poster mentioned, you will want to use the "jobs" command to see what is running in the background, however, the procedure for bringing the job to the foreground is to use:
$ fg %1
Where the "1" is the job number listed in the parens at the beginning of the line.
You also asked about nohup. It serves two purposes.
1) It installs a signal handler which ignores the HUP signal.
2) It redirects stdout and stderr to a file called nohup.out in the current directory
The reasons for #1 is:
If you run a program in the background, then exit the shell, the background program will be adopted by init, and init will immediately send that program the HUP signal which will cause
your background program to quit. By using "nohup", the HUP signal will be ignored and your background program will continue to run.
The reason for #2 is:
If you launch a program in the background and that program attempts to write to the terminal, then the shell will send the STOP signal to that program effectively pausing it.
- 06-12-2011 #4Just Joined!
- Join Date
- Apr 2011
- Posts
- 9
Ok. But when i put a process at background, the "jobs" command does give me nothing.
I have a process which i put it at back as:
./OPT aaa.txt &
where OPT: my application , aaa.txt: a input file
If i push jobs at com prompt, it does not give the process.
Why?
- 06-12-2011 #5Just Joined!
- Join Date
- May 2011
- Posts
- 3
- 06-12-2011 #6Just Joined!
- Join Date
- Dec 2009
- Location
- California
- Posts
- 69
Yeah, I agree with the previous poster. The job probably completed in the background.
Try it with the sleep command.
$ sleep 1000 &
$ jobs
[1] + Running sleep 1000 &
$ fg %1
sleep 1000
You ARE using a shell such as sh, bash, ksh, right? None of this stuff works in csh...
- 06-13-2011 #7Just Joined!
- Join Date
- Apr 2011
- Posts
- 9
OK thanks. I have done wrong! The jobs command works well.
Before i have tried to a run which terminated a few moment after of entrering of background.


Reply With Quote
