hmatt1
hmatt1

Reputation: 5159

Ran multiple instances of my program in the background at the same time, what do these return signs mean?

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?

Upvotes: 3

Views: 68

Answers (3)

jaypal singh
jaypal singh

Reputation: 77145

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.

Upvotes: 4

Brian Cain
Brian Cain

Reputation: 14619

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.

Upvotes: 1

ruakh
ruakh

Reputation: 183466

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.

Upvotes: 4

Related Questions