What do those +/- mean if linux job in background finishes (started with &)
-------------------------------------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Civilization
--
Chapters
00:00 Question
01:04 Accepted answer (Score 72)
01:57 Thank you
--
Full question
https://superuser.com/questions/559211/w...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #bash
#avk47
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Civilization
--
Chapters
00:00 Question
01:04 Accepted answer (Score 72)
01:57 Thank you
--
Full question
https://superuser.com/questions/559211/w...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #bash
#avk47
ACCEPTED ANSWER
Score 73
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.