Closing the terminal will kill all processes launched from its shell instance that are still running. Here is how to detach a running process and run+detach a new process:
Scenario 1:
Let’s say we have ./long.sh running, and we want to detach it:
./long.shPress Ctrl+Z to pause the process:
[1] bash: suspended ./long.shGet its job ID with the jobs command:
jobs
[1] + suspended ./long.shThen type bg, to run it in background:
bg %1
[1] bash: continued ./long.shUse disown to detach it:
$ disown %1
# Using its job IDScenario 2:
You can also run+detach a process with:
nohup ./long.sh &
# stdout and stderr will be put in a file.
Good stuff! Thanks!