Skip to main content

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 (i.e. how do I cause it to continue running even if I close the terminal?)


Source: Tips4allCCNA FINAL EXAM

Comments

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

    > [crtl]+z
    > bg


    And as Sam/Jan mentioned you have to execute disown to avoid killing the process after you close the terminal.

    disown -h

    ReplyDelete
  2. The command to seperate a running job from the shell ( = makes it nohup) is disown and a basic shell-command.

    From bash-manpage (man bash):


    disown [-ar] [-h] [jobspec ...]

    Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not
    removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is
    present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option
    means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return
    value is 0 unless a jobspec does not specify a valid job.


    That means, that a simple

    disown


    will remove all jobs from the job-table and makes them nohup

    ReplyDelete
  3. these are good answers above, I just wanted to add a clarification, You can't disown a pid or process, you disown a Job, and there is an important distinction. A Job is something that is a notion of a process that is attached to a shell. Therefore, you have to through the job into the background (not suspend it) and then disown it.

    issue:
    % jobs

    [1] running java

    [2] suspended vi

    % disown %1

    See http://www.quantprinciple.com/invest/index.php/docs/tipsandtricks/unix/jobcontrol/
    for a more detailed discussion of Unix Job Control.

    ReplyDelete
  4. Suppose for some reason Ctrl+Z is also not working, go to another terminal, find the process id (using ps) and run

    kill -20 PID
    kill -18 PID


    kill -20 will suspend the process and kill -18 will resume the process, in your other terminal

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex