Skip to content

How to close terminal without killing running processes on Linux

Advertisement

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.

Instructions

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
    [1]+  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
    
    [1]+ 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.

disown command example

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

2 Comments

  1. Thanks for the tut.
    Btw aren’t there codes for the same?
    lik kill -9 is for forece stop
    so I thouch CONT and STOP will have some codes…

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top