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.

Advertisement

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

Share.

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

Exit mobile version