Difference between revisions of "Linux command: bg"

From RHS Wiki
Jump to navigation Jump to search
(Created page with "bg and & If we add an & at the end of a command or script that we are executing it will execute in background<br /> ./my-shell-script.sh & [1] 10233 To pass a command that...")
 
m (Protected "Linux command: bg" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(No difference)

Latest revision as of 22:46, 8 April 2015

bg and & If we add an & at the end of a command or script that we are executing it will execute in background

./my-shell-script.sh &
[1] 10233

To pass a command that was executed in foreground to background without killing the process:

  1. Pause the process with CTRL + Z
$ ./my-shell-script.sh
^Z
[2]+  Detenido                my-shell-script.sh

Then unpause with:

$ bg
[2]+ my-shell-script.sh &

This process can be brought back with fg command:

$ fg 2
my-shell-script.sh