Created
November 30, 2016 13:10
-
-
Save masahiro-yoshitachi/a3412d119996e6ce94ff767784db4bca to your computer and use it in GitHub Desktop.
マルチスレッド風の処理(Bash)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### マルチスレッドで処理 | |
COMMAND_FILE=${SCRIPT_LOG}/`date '+%Y%m'`/`date '+%Y%m%d'`_$$_command_list.txt | |
n=8 | |
i=0 | |
while read line | |
do | |
# --- バックグラウンドで実行 | |
eval ${line} & | |
# 直前のPIDを取得 | |
pid[${i}]=$! | |
# --- 8以上になったら0を設定 | |
i=`expr $i \+ 1`; | |
if [ ${n} -eq ${i} ];then | |
wait; | |
i=0; | |
fi | |
done < ${COMMAND_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment