What does a "[1]+ Exit 1" response mean?
When you use the &
at the end of a command in bash, it runs the command in the background. The [1]+ Exit 1
means that job 1 exited with status 1. The number between the []
is the job number, and the number after Exit
is the exit status. If no exit status is shown, it means the command exited with status 0
.
The reason you don't see this until you run another command is because by default the status of a completed backgrounded command is not shown until the prompt is updated. This means after another command exits, or you simply press <ENTER>
on an empty prompt.
Edited:
You also do not need to use the nohup
. Bash will only HUP a process when the shell itself receives a HUP. This doesn't happen if you exit cleanly (via exit
, or CTRL+D).
However you can also use the disown
builtin to make it so specific jobs don't get a HUP.
Lastly you can also set a SIGHUP handler to disown all jobs when the shell gets a HUP by doing function sighup { disown -a; exit 0; }; trap sighup HUP
.
Patrick's answer is correct, although Stéphane's point about nohup
is important for users with differing versions. However, the significance of the + (plus) symbol was not given. Here, it indicates it is the "current" job. For instance, if I were to submit 3 commands at once as:
$ sleep 5&
[1] 29056
$ sleep 5&
[2] 29091
$ sleep 5&
[3] 29147
Then wait 5 seconds, and hit return, the output is:
[1] Done sleep 5
[2]- Done sleep 5
[3]+ Done sleep 5
As Patrick explained, the number between square brackets is an ordered job number. The + is only given for the latest job and the - is given for the job preceding it. All other jobs do not have any notation.