bashshelljob-schedulingnohupinterruption

How do I put an already-running process under nohup?


I have a process that is already running for a long time and don't want to end it.

How do I put it under nohup (that is, how do I cause it to continue running even if I close the terminal?)


Solution

  • Using the Job Control of bash to send the process into the background:

    1. Ctrl+Z to stop (pause) the program and get back to the shell.
    2. bg to run it in the background.
    3. disown -h [job-spec] where [job-spec] is the job number (like %1 for the first running job; find about your number with the jobs command) so that the job isn't killed when the terminal closes.