Task Management

Task Management

GNU/Linux is a multi-tasking system, which basically means that it provides resources to manage multiple tasks at the same time. A typical example would be a situation where we want to run a program but still need to work with the command prompt.

Such situation can be best solved by running the program in the background. This is achieved by putting the ampersand character (&) at the end of the command:

$ script.sh &

The program is now running, but its output does not interfere with your work with the command prompt. However, it will be necessary to bring the program to the foreground if you want to view it. This is done using the fg command. We are still going to need the identification number of the task, which can be displayed using the jobs command.

$ jobs
[1]+ script.sh &

$ fg 1

You don’t need to specify the number in case there is only one task running in the background. The same also applies if we want to bring the last “backgrounded” task to the foreground.

Additionally, we can also move a running task to the background. For this to happen, you need to stop the task using the key combination [CTRL]-[Z]. Afterwards, we can move it to the background using the bg command.

$ cp video.avi /pub/movies
[1]+ Stopped cp video.avi /pub/movies
$ bg 1

Even though it is very interesting to work with tasks, we shall stick to the introduction to their management and the multi-tasking system pages this time around. We will also take a look at task planning in the next part.

GNU/Linux allows task planning to run both one-time (using the at tool) and repeated (using the cron tool) tasks, depending on the parameters you enter. We will address both of these tools in greater detail in further parts.

Author: Jirka Dvořák

Best articles

Cooling system with freecooling technology in the server room
dedicated server Dell in our portfolio
VPS and VDS with 50% reduction on the price