Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Suppose test.sh is a bash script that is empty or contains only exit 0. When the script is backgrounded, what is the significance of the 1 and 16320 printed to the console?

b@sam:~/Documents/bashscripts$ ./test.sh &
[1] 16320
b@sam:~/Documents/bashscripts$ 
[1]+  Done                    ./test.sh
b@sam:~/Documents/bashscripts$ 

Then if user hits ENTER at the command prompt, as illustrated above, another line appears and it shows this

[1]+ Done ./test.sh

What is the significance of the 1 digit and the + symbol?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

[1] is the background job number, used for shell builtin commands like fg and bg which manage multiple tasks running in the same shell. jobs lists the current jobs.

16320 is the process ID number of the task, useful if you want to kill it or similar.

[1]+ Done indicates the background process has exited. Since you requested to run it in the background with ./test.sh &, it didn't wait for it to finish before giving you a fresh prompt (even though it finished almost immediately). The shell therefore notifies you the next time it gives you a prompt.

The + indicates the current (most recent) job, if you have multiple jobs running.

See the bash manual for more information.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.