Linux command: bg
Jump to navigation
Jump to search
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:
- 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