|
waitは、バックグラウンドプロセスの実行が終了するまで停止するコマンドである。
使用法wait [n] nが現在実行しているバックグラウンドプロセス(ジョブ)のPIDまたはジョブIDである。nが与えられていない場合、このコマンドはシェルが把握している全てのジョブが終了するまで停止する。 通常、
例このコマンドは、スクリプトの一部を並行で実行し、後ろの部分が前の部分の完了に依存するようなバリアを実装するときに役に立つ。 以下の(若干不自然な)例は、inoaという名前のホストからsrc/ディレクトリをrsyncで取り込み、同時にこのプログラムが依存するライブラリを更新し、これらを組み合わせてビルドを実行する。 #!/bin/bash # Parallel update script which makes use of the wait command # Update local copy rsync iona:src/ . & # Upgrade required libraries, or exit indicating failure if make failed for some reason make -C lib || exit 1 # Wait for rsync to terminate (may have already happened) and finish the job, unless rsync failed wait && make 関連項目外部リンク
|
||||||||||||||||||||||||||||||||||||||||||
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net