Skip to content

jobs MacOS Command Guide

The MacOS ‘jobs’ command is a built-in utility that allows users to manage background jobs. This command displays a list of all current jobs running in the background of your terminal session. By using this command, you can view the job ID, status, and the command that started the job. It is especially useful when you have multiple processes running simultaneously and need to keep track of them. Additionally, you can use the ‘jobs’ command to bring background jobs to the foreground, suspend jobs, or terminate them. This guide will walk you through the basics of using the ‘jobs’ command effectively on your MacOS system.

Terminal window
jobs [options]
OptionDescription
-lDisplay process ID and status for each job.
-pDisplay process group IDs only.
-rDisplay only running jobs.
-sDisplay only stopped jobs.
ParameterDescription
None
Terminal window
jobs

Displays a list of current jobs running in the background.

Terminal window
sleep 10 &

Runs the “sleep 10” command in the background for 10 seconds.

Terminal window
fg 1

Brings job number 1 to the foreground.

Terminal window
bg 2

Sends job number 2 to the background.

Terminal window
kill %1

Terminates the job with job ID 1.

Terminal window
jobs -l

Lists all jobs, including their PIDs and statuses.

Terminal window
kill -STOP %1

Suspends the job with job ID 1.

To use the jobs command in MacOS, execute the following command:

Terminal window
jobs

To list all active jobs in MacOS, use the following command:

Terminal window
jobs -l

Is there a way to display PID along with jobs in MacOS?

Section titled “Is there a way to display PID along with jobs in MacOS?”

Yes, you can display the PID along with jobs in MacOS using the following command:

Terminal window
jobs -p

How can I bring a background job to the foreground in MacOS?

Section titled “How can I bring a background job to the foreground in MacOS?”

To bring a background job to the foreground in MacOS, you can use the following command:

Terminal window
fg %<job_number>

Can I stop a background job in MacOS using the jobs command?

Section titled “Can I stop a background job in MacOS using the jobs command?”

Yes, you can stop a background job in MacOS using the jobs command. Here is an example:

Terminal window
kill -STOP %<job_number>

To resume a stopped job in MacOS, use the following command:

Terminal window
kill -CONT %<job_number>
  • View a list of all currently active jobs in the shell
  • Manage multiple processes running in the background
  • Check the status of background jobs
  • Bring background jobs to the foreground
  • Terminate or suspend specific background jobs