実行中のプロセスにSIGHUPを無視するように指示するにはどうすればよいですか? [コピー]

実行中のプロセスにSIGHUPを無視するように指示するにはどうすればよいですか? [コピー]

重複の可能性:
実行中のコマンドを終了せずに端末を閉じるにはどうすればよいですか?

私は時々SSH経由でアクセスするDebian Squeezeを実行する低コストの「サーバー」を持っています。システムが遅い傾向があります。たとえば、apt-cache search実行には30分かかります。時にはプロセスが完了するのを待つことができないことがわかります(ノートブックを使用しているので、別の場所に行く必要があります)。

nohupscreen最初に。しかし、ログアウトしてもすでに実行中のプロセスを実行し続けるにはどうすればよいですか?

答え1

bash、ksh、zsh、または他の同様のシェルを使用していると仮定すると、プロセスをバックグラウンドに置いて実行できますdisown。具体bash的には、次のものが必要な場合がありますdisown -h

Bashヘルプページから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.

答え2

disownBashまたはzshを使用している場合は、ログアウトする前に組み込みコマンドを使用してください。

から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.

関連情報