3

I just kicked off a bunch of instances (17) of my program to test them running concurrently. This is what the terminal output looked like near the end.

    [9]   Done                    perl test.pl -a
    [10]   Done                    perl test.pl -a
    [11]   Done                    perl test.pl -a
    [12]   Done                    perl test.pl -a
    [13]   Done                    perl test.pl -a
    [14]   Done                    perl test.pl -a
    [15]   Done                    perl test.pl -a
    [16]-  Done                    perl test.pl -a
    [17]+  Done                    perl test.pl -a

The 17th was the last one. I was wondering, what does the [16]- and [17]+ mean? Just that they were the last two processes to finish?

daxim
  • 39,270
  • 4
  • 65
  • 132
hmatt1
  • 4,939
  • 3
  • 30
  • 51

3 Answers3

4

From §7.1 "Job Control Basics" in the Bash Reference Manual:

Job number n may be referred to as ‘%n’. The symbols ‘%%’ and ‘%+’ refer to the shell’s notion of the current job, which is the last job stopped while it was in the foreground or started in the background. A single ‘%’ (with no accompanying job specification) also refers to the current job. The previous job may be referenced using ‘%-’. If there is only a single job, ‘%+’ and ‘%-’ can both be used to refer to that job. 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 ‘-’.

(emphases mine).

So it's not that they were the last ones to finish, but that they were the last ones to be started in the background.

ruakh
  • 175,680
  • 26
  • 273
  • 307
  • I picked this answer because it had the link to the man page. The other answers were helpful too. Thanks for the quick responses! – hmatt1 Jul 04 '13 at 01:47
4

This is from the bash man page:

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 -.

So basically + behind the [17] is because it was the last job started and the - behind [16] is because that was the previous job.

jaypal singh
  • 74,723
  • 23
  • 102
  • 147
1

From the bash manpage:

JOB CONTROL ...

When bash starts  a  job
   asynchronously (in the background), it prints a line that looks like:

          [1] 25647 

...

The previous job may be referenced using %-. 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 -. A single % (with no accompanying job specification) also refers to the current job.

Brian Cain
  • 14,403
  • 3
  • 50
  • 88