LoginSignup
3
3

More than 5 years have passed since last update.

GNU Parallel のエラー処理

Last updated at Posted at 2017-11-28

シェルスクリプトで並列処理をしたいとき、便利なのがxargs -P ですがエラー時に終了させることができません。
(できるようでしたら教えてください)

GNU Parallel を使うと簡単にエラー時の制御ができます。

例)3並列で long_job を実行。エラー時は 即座に終了

$ cat list.txt | parallel --halt now,fail=1 --jobs 3 ./long_job {}

なお、実行中の他の処理の終了を待って終了するには、now の代わりに soon を指定します。

例)3並列で long_job を実行。エラー時は 他のプロセスの終了を待って終了

$ cat list.txt | parallel --halt soon,fail=1 --jobs 3 ./long_job {}

参考

3
3
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
3
3