For example, you are running time-consuming processes and you don’t want that job killed due to terminal closed. To handle this situation, you can simply remove a job from an active job table. So that the job will not be killed when the terminal is closed.
Follow the below instruction to detach running jobs from the terminal.
- 1. Press CTRL + Z to suspend current running process.
zip -q -r home.zip * ^Z + Stopped zip -q -r home.zip *
- 2. Then run the stopped process in the background by running bg command. It will put the last stopped process to background.
bg + zip -q -r home.zip * &
- 3. Finally, remove the above job from the table of active job. Use [disown -h jobspec] where [jobspec] is the job number of background running job. Like %1 for the first running job.
disown -h %1
Note: Here 1 is the job ID of background running job. You can also use the “jobs -l” command to find job id.