LoginSignup
47
42

More than 5 years have passed since last update.

sshでのプロセス継続をnohupで行う際のメモ

Last updated at Posted at 2013-12-12

大改訂すべきだけど、ちょっと面倒なので

まず先にこっちも読んでおいてください。
http://www.glamenv-septzen.net/view/854

以降は通常はそうしておくというもの

sshした中で、プロセス切り離しやbgでのバックグラウンド動作へ変更などすることがある。が、それはsshの特性から、なにもしないでやっちゃってssh抜けるとプロセスが死ぬ。
これはnohupで実行する必要がある。1

あと、リモートコマンドは標準入出力のリダイレクトも必要となる。2

で、これやるときに、標準出力とエラーをまとめたいんだが、記述をよくわすれるのでメモ3

command.sh
# bash
nohup [command] < /dev/null 2>&1 /dev/null &
command.sh
# tcsh
nohup [command] < /dev/null >& /dev/null &

でいいはず。

ただ、最近のnohupだとnohup [command] > /dev/null &でよさげ
stdinを/dev/nullからの入力、stderrをstdoutにリダイレクトする、らしいので(確認はあんまりしていない)

47
42
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
47
42