Jobs in Linux
A job is a conceptual thing in Linux. With Job you can manage your own processes and send them in background and foreground.
A job can be sent in background in 2 ways.
- using CTRL+z shorcut key. In this case, job is in suspended mode.
- using & at the end of the command in shell. In this case, job is in running status in the background
To view all jobs in the background, you can use “jobs” command.
To get the job in foreground, you need to use “fg” command. This will get the most recent background job to the foreground.
But you can also get specific job to the foreground using below command.
You can kill the job using below syntax.
bg command can be used to resume suspended jobs in the background.
Main purpose of sending the job to background is that you can work on multiple jobs at the same time and you do not need to wait for the job to finish before starting new one.
You can use “disown” command to remove specific job from the list of jobs.
“wait” command is used to wait until background jobs have finished.
“suspend” command has the same effect as pressing hotkey “ctrl+z”