0
0
Linux CLIscripting~5 mins

jobs command in Linux CLI - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you start tasks in the background on your computer and want to see what is still running or stopped. The jobs command helps you list these background or paused tasks so you can manage them easily.
When you have started a long task in the background and want to check if it is still running.
When you paused a task using Ctrl+Z and want to see its status before resuming or stopping it.
When you want to bring a background task back to the foreground to interact with it.
When you want to clean up stopped or background jobs before closing your terminal session.
Commands
Starts a simple task that waits for 100 seconds in the background so we have a job to list.
Terminal
sleep 100 &
Expected OutputExpected
[1] 12345
Lists all current background and stopped jobs in this terminal session.
Terminal
jobs
Expected OutputExpected
[1]+ Running sleep 100
Starts a task in the foreground that waits for 200 seconds.
Terminal
sleep 200
Expected OutputExpected
No output (command runs silently)
Pauses the foreground task and sends it to the background as a stopped job.
Terminal
Ctrl+Z
Expected OutputExpected
[2]+ Stopped sleep 200
Lists all jobs again, showing the new stopped job.
Terminal
jobs
Expected OutputExpected
[1]- Running sleep 100 [2]+ Stopped sleep 200
Key Concept

If you remember nothing else from this pattern, remember: the jobs command shows you all background and stopped tasks in your current terminal session so you can manage them.

Common Mistakes
Trying to use jobs command without any background or stopped jobs.
The jobs command will show no output, which can confuse beginners into thinking it is broken.
Make sure you have started a background job (using & or Ctrl+Z) before running jobs.
Expecting jobs to show tasks started in other terminal windows or sessions.
Jobs only shows tasks started in the current terminal session, so other terminals' jobs won't appear.
Use jobs only to manage tasks in the current terminal window.
Not using Ctrl+Z to pause a foreground job before trying to list it with jobs.
Foreground jobs are not listed by jobs until paused or backgrounded.
Pause a running foreground job with Ctrl+Z to see it in jobs.
Summary
Use the jobs command to list all background and stopped tasks in your current terminal session.
Start a task in the background by adding & at the end of the command or pause a foreground task with Ctrl+Z.
Check the status of your jobs anytime with jobs to decide if you want to resume or stop them.