GNU/Linux >> Linux の 問題 >  >> Linux

すでに開始されているプロセスを nohup/screening できますか?

解決策 1:

Bash を使用している場合は、disown -h job を実行できます。

<ブロック引用>

否認

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

オプションを指定しないと、アクティブなジョブのテーブルから各ジョブスペックが削除されます。-h の場合 オプションを指定すると、ジョブはテーブルから削除されませんが、シェルが SIGHUP を受信した場合にジョブに SIGHUP が送信されないようにマークされます。 jobspec が存在せず、-a のいずれでもない場合 -r でもありません オプションが指定されている場合、現在のジョブが使用されます。 jobspec が指定されていない場合、-a オプションは、すべてのジョブを削除またはマークすることを意味します。 -r jobspec 引数のないオプションは、操作を実行中のジョブに制限します。

解決策 2:

Reptyr を使用

README から:

reptyr - A tool for "re-ptying" programs.
-----------------------------------------

reptyr is a utility for taking an existing running program and
attaching it to a new terminal. Started a long-running process over
ssh, but have to leave and don't want to interrupt it? Just start a
screen, use reptyr to grab it, and then kill the ssh session and head
on home.

USAGE
-----

  reptyr PID

"reptyr PID" will grab the process with id PID and attach it to your
current terminal.

After attaching, the process will take input from and write output to
the new terminal, including ^C and ^Z. (Unfortunately, if you
background it, you will still have to run "bg" or "fg" in the old
terminal. This is likely impossible to fix in a reasonable way without
patching your shell.)

著者によるいくつかのブログ投稿:

  • reptyr:実行中のプロセスを新しい端末に接続します
  • reptyr:プロセスの制御端末の変更

解決策 3:

ある tty から現在の tty にプロセスを盗むには、次のハックを試してください:

http://www.ucc.asn.au/~dagobah/things/grab.c

現在の Linux/glibc バージョンにコンパイルするには再フォーマットが必要ですが、それでも動作します。

解決策 4:

プロセスが開始されると、STDIN、STDOUT、および STDERR が 何か に接続されます .通常、コマンドが開始されると、それを変更することはできません。あなたが説明している場合、それはおそらくsshセッションに関連付けられたttyです。 nohup はほとんど...

command < /dev/null > nohup.out 2>&1

つまり、STDIN を /dev/null に、STDOUT をファイルに、STDERR を STDOUT に設定します。 Screen は、自分自身に向ける tty のセットアップを含む、はるかに洗練された処理を行います。

実行中のプロセスをさかのぼって nohup またはスクリーン化する方法はわかりません。 /proc/$pid/fd に cd して、0、1、および 2 が何を指しているかを確認します。

disown で運が良いかもしれませんが、プロセスが STDIN、STDOUT、または STDERR で何かを行おうとする場合はそうではありません。

解決策 5:

画面部分の理由がなければ、単純に「いいえ」としか言えません。その理由については、あなた自身が知りたいと思います.

ただし、disown を試しましたか (bash ビルトイン)

~ $ echo $SHELL
/bin/bash
~ $ type disown
disown is a shell builtin
~ $ help disown
disown: disown [-h] [-ar] [jobspec ...]
     By default, removes each JOBSPEC argument from the table of active jobs.
    If the -h option is given, the job is not removed from the table, but is
    marked so that SIGHUP is not sent to the job if the shell receives a
    SIGHUP.  The -a option, when JOBSPEC is not supplied, means to remove all
    jobs from the job table; the -r option means to remove only running jobs.

Linux
  1. Ssh –実行中のプロセスを破棄して新しいスクリーンシェルに関連付ける方法は?

  2. Linux で Ctrl-Alt-F6 を使用しましたが、画面が元に戻りません

  3. PID ではなく名前でプロセスを強制終了するにはどうすればよいですか?

  1. GDB を使用して実行中のプロセスをデバッグできますか?

  2. Linuxでスクリーンプロセスを停止するには?

  3. スワップを使用しているプロセスを知るにはどうすればよいですか?

  1. Ctrl + C でプロセスを強制終了できない場合はどうすればよいですか?

  2. 既存の vim プロセスを再開できますか?

  3. 複数の画面セッションを自動的に開始するにはどうすればよいですか?