Languages
[Edit]
EN

Bash - work with multiple tasks

6 points
Created by:
martineau
450

In this article, we would like to show you how to work with multiple tasks in Bash.

Preview:

Example how to switch between multiple tasks in Bash.
Example how to switch between multiple tasks in Bash.

Simple steps:

1. run some command that blocks console, e.g.:

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)

now you can run more commands and press Ctrl+Z

3. run the following command to display background jobs

jobs -l

Where -l is optional and means list.

Example output:

[1]- 34835 Stopped                 sleep 60
[2]+ 34836 Stopped                 sleep 60

4. to bring the process back to the terminal (attaching) run the following command:

fg process_number

e.g:

fg 1

# or:

fg 2
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join