0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[fish-shell] [04] ある外部コマンドを並列実行させる

Posted at

概要

my_script_1.sh、my_script_2.sh、my_script_3.sh、my_script_4.sh、
を並列で実行させて、全ての終了を待つ処理である.

fish-shell V2.7.1 で動作確認済み.

fish-shell 3.0 では wait コマンドが実装されたようなので、
下記のような実装はしなくて良いのだと思う (未検証)

fish 3.0がやってきた

コード

#!/usr/bin/env fish

# my_script_1.sh 〜 my_script_4.sh を並列実行させる
for i in ( seq 1 4 )
  sh my_script_$i.sh &
end

# my_script_1.sh 〜 my_script_4.sh の終了を待つ
while true
  set -l bg_jobs ( builtin jobs -p 2>/dev/null )
  sleep 0.5
end

echo Finished.

以上.

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?