Linux jobs Command
Learn Linux jobs Command with examples
Published
- Linux jobs Command
- Find out whether jobs is part of shell
- jobs Command Syntax
- jobs JOB Name or Number Options
- jobs Command Example
- jobs -p Command
- jobs -r Command
- jobs -l Command
- jobs -s Command
Linux jobs Command
In Linux, we can use “jobs” command is used to list the jobs that you are running in the background and in the foreground.
Note: All shells are not capable of running this command. This command is only available in the csh, bash, tcsh, and ksh shells.
Find out whether jobs is part of shell
to find out whether jobs is part of shell, external command or both:
>> type -a jobs
>> command -V jobs
jobs is a shell builtin
jobs is a shell builtin
jobs Command Syntax
>> jobs [JOB]
jobs JOB Name or Number Options
JOB | Job name or number. |
-l | Lists process IDs in addition to the normal information. |
-n | List only processes that have changed status since the last notification. |
-p | Lists process IDs only. |
-r | Restrict output to running jobs. |
-s | Restrict output to stopped jobs. |
jobs Command Example
>> jobs
If the prompt is returned with no information no jobs are present.
In case there is no job exist then let’s create a job.
First, start a new job as follows:
>> sleep 120 &
Now, only show jobs that have stopped or exited since last notified, type:
>> jobs -n
[1]+ Running sleep 120 &
jobs -p Command
To display the process ID or jobs for the job whose name begins with “s”.
>> jobs -p %s
>> jobs %s
153
Note: Job id may be different.
The character % introduces a job specification.
In this example, you are using the string whose name begins with suspended command such as %ping.
jobs -r Command
jobs -r option to jobs command to display only running jobs only.
>> jobs -r
Output:
[1] Running gpass &
[2] Running gnome-calculator &
[3]- Running gedit fetch-stock-prices.py &
jobs -l Command
jobs -r show process IDs in addition to the normal information
>> jobs -l
jobs -s Command
jobs -s display only jobs that have stopped
>> jobs -s