What do those +/- mean if linux job in background finishes (started with &)
Solution 1:
From man bash
:
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.
It is also the one that will be brought into the foreground when fg
is used without arguments:
$ /tmp/script &
[1] 9871
$ /tmp/script2 &
[2] 9876
$ /tmp/script3 &
[3] 9881
$ /tmp/script4 &
[4] 9886
$ jobs
[1] Running /tmp/script &
[2] Running /tmp/script2 &
[3]- Running /tmp/script3 &
[4]+ Running /tmp/script4 &
$ fg
/tmp/script4
The job flagged with a -
was sent to the background second last. Other background jobs are not flagged.