LoginSignup
10
11

More than 5 years have passed since last update.

ログアウトしてもバックグラウンドジョブがこの先生きのこるには

Posted at

n番煎じなネタですが……。

概要

退社前にあるサーバに SSH 接続して時間のかかる処理を
バックグラウンド (コマンドの末尾に & を付加する) で実行し、
そのまま定時退社したいですよね。
でも SSH 接続を切るとジョブが死んじゃう!どうしたらいいの!

こんなときは nohup の出番でござる。

本来はログアウトの際に、そのとき実行していたプロセスに対して自動的に SIGHUP シグナルが送られてプロセスは終了します。
しかし nohup で実行すれば、この SIGHUP シグナルを無視してくれるようになります。

How to Use

$ nohup ./sugoku_omoi_script.sh &

標準出力・標準エラー出力先を指定する場合
(この場合、標準入力を閉じておく必要があるそうです。)

$ nohup ./sugoku_omoi_script.sh > out.log 2> err.log < /dev/null &

参考

10
11
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
10
11