LoginSignup
14
17

More than 5 years have passed since last update.

nohupを使ってログアウト後もコマンド実行するようにする

Posted at

sshでサーバにログインして処理時間が長いコマンドを実行すると、sshが途中で切れて処理自体も終了することがあるかと思います。そんな時に便利なのがnohupコマンドです。

これを使えば、ログアウトした後もバックグラウンドでコマンドされるので、長い処理でも最後まで実行されます。

実際の使い方はこんな感じです。下のような使い方でlogファイルを指定します。&でバックグラウンドで実行。

$ ssh username@host
/* サーバにログイン*/
$ nohup コマンド &

$ nohup find / -name 'test*' > result.log &

参考記事

http://www.codereading.com/nb/ignore-the-hangup-signal.html
http://itref.fc2web.com/unix/shell.html

14
17
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
14
17