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?
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?
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
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.