35

sshさて、それはこのようになります、私は私の機関のサーバーに接続することによって私の家からプログラムを実行しなければなりませんでした。セッションが終了したときにプログラムを終了したくありませんでした(私は知りませんでしたscreen)。

私がしたことは、それがバックグラウンドで実行されるように押しCtrl+Zてから入力することでした。bgセッションが終了しました。教育機関のマシンからログインして「」と入力ps -u usernameすると、プログラムはまだ実行中であることが示されますが、フォアグラウンドに移動できません。

試しfgましjobsたが、これらのコマンドでは出力が得られません。
誰か助けてください。

4

3 に答える 3

30

「screen」コマンドを使用せずにプロセスを開始した場合、そのプロセスを引き継ぐことはできません。基本的に、別のシェルで開始されたプロセスを引き継ぐことはできません。

セッションが終了すると、すべてのbgプロセスがデタッチ状態になります。そのようなプロセスの詳細を見ることができるかもしれませんが、後でログインからシェルにそれらをfgすることはできません

于 2012-08-13T07:45:54.543 に答える
11

If a process has been orphaned, you can't "reparent" it to a different shell and use fg, bg, ^Z, ^C, and so forth to control it.

It seems you're asking implicitly how to control an orphaned process. Since you can see the process using the ps command, you have its pid. You can use this pid as the argument to the kill command, which will allow you to stop, continue, or terminate the process. You can't wait for the process to finish, but you can poll to see whether it still exists by using the "kill -0 <pid>" command.

于 2012-08-13T07:51:12.890 に答える
6

https://serverfault.com/questions/55880/moving-an-already-running-process-to-screen

この質問に対する別の見方を示します。一番上の答えは、Reptyrの使用を提案しています。

于 2014-03-24T17:05:53.530 に答える