サーバーのよく使うコマンドメモ| nohup

2015年2月13日

コマンド サーバー テクノロジー

Summery

コマンドをバックグラウンドで実行させる。 ※遠隔ssh操作などで、時間のかかるバッチ処理などを行う場合、ターミナル端末が離席中にスリープ状態になってしまうと、コマンド実行が中断されてしまう場合がある。 このコマンドをつけると、ターミナルを終了しても、バッチは終了まで実行される。

Construction

$ nohup [command]

Option

command : 通常のコマンドライン入力

Sample

# 長時間かかるバッチ処理のshellプログラムをバックグラウンドで実行 $ nohup sh hoge.sh

Coution

バックグラウンドでバッチを実行する場合は、実行直後から、ターミナルと切り離されるので、-vオプションなどのコマンド実行経過を目視することができない。 バッチファイルなどであれば、ログをファイルに書き出して、tailコマンドと組み合わせて行うと効率的に作業できる。

Discription

The nohup utility invokes utility with its arguments and at this time sets the signal SIGHUP to be ignored. If the standard output is a terminal, the standard output is appended to the file nohup.out in the current directory. If standard error is a termi- nal, it is directed to the same place as the standard output. Some shells may provide a builtin nohup command which is similar or identical to this utility. Consult the builtin(1) manual page.

このブログを検索

ごあいさつ

このWebサイトは、独自思考で我が道を行くユゲタの少し尖った思考のTechブログです。 毎日興味がどんどん切り替わるので、テーマはマルチになっています。 もしかしたらアイデアに困っている人の助けになるかもしれません。