You can start a process, command, or application in the background by prepending the process, command, or application with an ampersand (&).
Example:
Start a single background process:
1 2 3 4 5 6 7 8 9 10 11 12 |
## For single background process ## Start a process or command or application in background sleep 600 & ## returns [1] 85 ## List all backgroud process in Linux jobs ## returns [1]+ Running sleep 600 & ## Get the process id of a background process in Linux echo $! ## returns 85 ## Kill a background process in Linux kill $! ## returns [1]+ Terminated sleep 600 |
Start multiple background processes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
## For multiple background processes ## Start multiple processed or commands or applications in background sleep 600 & ## returns [1] 92 sleep 600 & ## returns [1] 93 sleep 600 & ## returns [1] 94 ## List all backgroud process in Linux jobs -l ## returns ## [1] 92 Running sleep 600 & ## [2]- 93 Running sleep 600 & ## [3]+ 94 Running sleep 600 & ## Get the process id of all background processes jobs -p ## returns 92, 93, 94 ## Kill all background process kill $(jobs -p) ## returns ## [1] Terminated sleep 600 ## [2]- Terminated sleep 600 ## [3]+ Terminated sleep 600 |