Operating System - HP-UX
1751845 Members
5519 Online
108782 Solutions
New Discussion юеВ

Re: How to switch to a process in the background?

 
SOLVED
Go to solution
YMJ
Frequent Advisor

How to switch to a process in the background?

I normaly like to throw processes in the background and leave them till they finished.
but I think sometimes this is not a good idea. The problem for me is I through the process of fbackup command during my normal full backup to the system. Then, when the system request for a second tape, I didn't know how to switch back to fbackup process and type y to continue with the backup?
6 REPLIES 6
John Poff
Honored Contributor

Re: How to switch to a process in the background?

Hi,

If you kick off a script or command something like this:

dosomething [some options] &

you should be able to get back to it by doing:

fg

and then answer your prompt.

JP
Darrell Allen
Honored Contributor
Solution

Re: How to switch to a process in the background?

Hi,

Presuming you are using the posix shell, do "man sh-posix" and look at the section "Jobs".

You can reference background processes several ways. Normally, I use the %number method. You can use the "jobs" command and then "fg %number" to bring a process back to the foreground.

Here's a very simple example:

$ sleep 120&
[1] 5600
$ sleep 60&
[2] 5601
$ sleep 30&
[3] 5602
$ jobs
[3] + Running sleep 30&
[2] - Running sleep 60&
[1] Running sleep 120&
$ fg %2
sleep 60

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Helmuth Viets
New Member

Re: How to switch to a process in the background?

Hi,
you should find out which job-number your process has. Then get the process into the fg and after you answered "y" you can put the process back into the background. Try this procedure:
1. jobs -> to get the job number (e.g. 1)
2. fg %1 -> process into fg
3. y -> your response to fbackup
4. bg %1 -> back to where it came from
I hope it helps

HV
Education Consulting
Ashwani Kashyap
Honored Contributor

Re: How to switch to a process in the background?

fg is the command to bring back background process in foreground .
Jean-Louis Phelix
Honored Contributor

Re: How to switch to a process in the background?

hi,

- to launch in background, add a '&' at the end

- to put in foreground use fg command
$ jobs
get the number
$fg %number

- to put it in background if no '&'
You can't use bg ... You have to use control key defined for 'susp' in stty -a. I usually set it to CTRL-Z
$ stty -a
...
stop = ^S; start = ^Q; susp = ^Z; dsusp
...
If your susp is not set, you can still put it in background using a kill -SIGSTOP from another window.

When jobs indicates that a job is stopped, it's the only case when you can use 'bg' command to continue it in background

Regards
It works for me (┬й Bill McNAMARA ...)
Bill McNAMARA_1
Honored Contributor

Re: How to switch to a process in the background?

Check out his link:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xa2decdec06f1d61190050090279cd0f9,00.html

ie: put
stty susp ^Z
in : ~/.profile

Later,
Bill
It works for me (tm)