In an interactive bash shell running inside lxterminal, if I run a background job
$ evince &
and then close the shell, the background job will be killed.
If I put the background command in a script, and run the script in an interactive bash shell:
$ cat test.sh !# /bin/bash evince & $ ./test.sh $
after the script terminates, the background job still runs. Even after I terminates the interactive bash shell, the background job still continues running.
I wonder why putting a background job into a script and running the script can make the job survive both the termination of the script and the termination of the caller of the script? Is wrapping a job into a script a good way to make the job survive the termination of the script and the termination of the shell which invokes the script?