Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How can I close a terminal without killing the command running in it?

I have a very low-end "server" running Debian Squeeze that I occasionally ssh to. The system tends to be slow, e.g. running apt-cache search might take half a minute. Occasionally I find that I can't wait for a process to complete (I'm on my laptop and need to go somewhere).

If I had originally started the process with nohup or inside screen, this would be no problem. But how can I get an already running process to continue despite my logging off?

share|improve this question
add comment

marked as duplicate by Mikel, Renan, jasonwryan, jw013, rahmu Nov 7 '12 at 22:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 10 down vote accepted

On the assumption that you are using bash, ksh, zsh, or another similar shell, you can background the process, then run disown. Specifically, in bash you probably want disown -h.

From bash's help page on disown:

disown: disown [-h] [-ar] [jobspec ...]
    Remove jobs from current shell.

    Removes each JOBSPEC argument from the table of active jobs.  Without
    any JOBSPECs, the shell uses its notion of the current job.

    Options:
      -a        remove all jobs if JOBSPEC is not supplied
      -h        mark each JOBSPEC so that SIGHUP is not sent to the job if the
        shell receives a SIGHUP
      -r        remove only running jobs

    Exit Status:
    Returns success unless an invalid option or JOBSPEC is given.
share|improve this answer
    
Great! I thought something like this must exist. Thanks! –  dancek Nov 12 '11 at 15:25
3  
Note that this tells the shell not to send a SIGHUP to the process when the shell itself receives a SIGHUP. It won't protect the process from receiving a SIGHUP from another source (either from the terminal if the process has become a session leader — which doesn't typically happen — or sent explicitly). –  Gilles Nov 12 '11 at 19:58
    
True, but there is no way to do that (aside from changing the way that the program were to handle SIGHUP, but that would require a source change). –  Chris Down Nov 12 '11 at 20:48
add comment

If you use bash or zsh use the built-in disown before logging off.

From man zshall:

   disown [ job ... ]
   job ... &|
   job ... &!
          Remove the specified jobs from the job table; the shell will  no
          longer  report their status, and will not complain if you try to
          exit an interactive shell with them running or stopped.   If  no
          job is specified, disown the current job.
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.