EN
Bash - work with multiple tasks
6 points
In this article, we would like to show you how to work with multiple tasks in Bash.
Preview:

Simple steps:
1. run some command e.g. that blocks console:
xxxxxxxxxx
1
sleep 60
Hint: to run the command directly in the background add
&
at the end, e.g.sleep 60 &
.
2. press Ctrl
+Z
to put command to the background (detaching)
Hint: now you can run more different commands and press
Ctrl
+Z
3. to display background jobs run the following command:
xxxxxxxxxx
1
jobs -l
Where -l
is optional and means list.
Example output:
xxxxxxxxxx
1
[1]- 34835 Stopped sleep 60
2
[2]+ 34836 Stopped sleep 60
4. to stop the process use the following command:
xxxxxxxxxx
1
kill %process_number
e.g:
xxxxxxxxxx
1
kill %1
2
3
# or:
4
5
kill %2
5. to bring the process back to the terminal (attaching) run the following command:
xxxxxxxxxx
1
fg process_number
e.g:
xxxxxxxxxx
1
fg 1
2
3
# or:
4
5
fg 2