Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the suffixes "+" and "-" after the job id of background jobs mean?

When I run several background processes my output of the command jobs is for example:

[1]-  RUNNING                  nohup somecommand1 &
[2]+  RUNNING                  nohup somecommand2 &

What do the "+" and "-" chars after the job id mean?

like image 969
Benjamin Avatar asked Mar 05 '12 09:03

Benjamin


People also ask

What is +/- in background jobs in Linux?

In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a + , and the previous job with a - . That is, the job flagged with a + is the one that was sent to the background last.

What is the job ID in Linux?

Job numbers refer to background processes that are currently running under your shell, while process IDs refer to all processes currently running on the entire system, for all users. The term job basically refers to a command line that was invoked from your shell.

How do I find my job identification number?

The job IDs can be displayed using the jobs command, the -l switch displays the PID as well. Some kill implementations allow killing by job ID instead of PID. But a more sensible use of the job ID is to selectively foreground a particular process.

Which key sequence suspends a job and resume it in the background?

On an empty command line runs bg (so that Ctrl+Z Ctrl+Z suspends a program and immediately resumes it in the background).


1 Answers

It's in the man-page for jobs under STDOUT:

> man jobs

The character '+' identifies the job that would be used as a default for the fg or bg utilities; this job can also be specified using the job_id %+ or "%%" . The character '-' identifies the job that would become the default if the current default job were to exit; this job can also be specified using the job_id %-.

So the job marked with '+' is the one that will be activated by 'fg'.

like image 90
ibab Avatar answered Nov 15 '22 20:11

ibab