0

This question already has an answer here:

Suppose I run a process in the background likw ./script &, I can bring it to foreground by running fg.

However, is there a way to move it back to background without stopping it (as in ctrl+z) or opening a new session?

marked as duplicate by Stéphane Chazelas shell Aug 7 '14 at 14:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

This is not possible. I usually do CTRL-Z and %1& or bg 1 where '1' is the job number.

If you have a separate terminal and know the process id, you can do kill -20 500; kill -18 500 (if your process id is 500) to first suspend and then start in background.

2

What you are asking is not possible. You can however do the following

[usr@localhost:~]$ sleep 100 &
[1] 28542
[usr@localhost:~]$ fg
sleep 100
^Z
[1]+  Stopped                 sleep 100
[usr@localhost:~]$ bg
[1]+ sleep 100 &
[usr@localhost:~]$ jobs -l
[1]+ 28542 Running                 sleep 100 &

Another alternative is to use screen or tmux

  • problem with screen is that I need to decide before hand. This was the rare occasion where the bring back is unplanned :) – vpillai Aug 7 '14 at 14:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.