3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sshでコマンド実行の際、&を付けてバックグラウンドで実行してもsshが終わらない。

Last updated at Posted at 2016-09-01

※CentOS7環境下で確認しています。

journalctl -f -o json | ncat localhost 1111 &
を普通に実行したらプロンプトに戻るのに
ssh経由で
ssh server "journalctl -f -o json | ncat localhost 1111 &"
を実行した場合、sshが終了しなくなってしまう。

標準出力、エラー出力を/dev/nullもしくはLogに保存するようにすると返ってくる。
ssh server "journalctl -f -o json | ncat localhost 1111 >/dev/null 2>&1 &"

おそらくsshはプロセスから標準出力が切断されるまで待つがjournaldを
-fで動かしたときは標準出力を繋ぎ続けるため終了しなくなると思われる。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?