If a process is running and we don't want to stop it, even after closing the terminal, then we put it under nohup, so that it will still execute even after closing the terminal.
We can achieve this by using the following command.
# disowns all processesdisown -a
We need to follow the process below to make it work.
disown -a
.Let's take a look at an example.
We'll use the following code snippet, which takes a long time to execute.
for num in {1..1000000}doecho $numdone | tee my_job.log
As specified in the above steps,
+
sign to initiate the second terminal. We'll also need to open the second terminal.disown -a
, while the code still executing in the first terminal.cat my_job.log
, the log file we stored.