1. 程式人生 > >Shell指令碼併發池控制

Shell指令碼併發池控制

控制個數為10個

dbname=$1

tempfifo=$$.fifo        # $$表示當前執行檔案的PID
mkfifo $tempfifo
exec 10<>$tempfifo
rm -rf $tempfifo

for ((i=1; i<=10; i++))
do
    echo >&10
done

for tbname in $(impala-shell --quiet -B -q "use $dbname;show tables;"|cat)
do
		read -u10
		
        {
		echo "use $dbname;MSCK REPAIR TABLE ${tbname};"
        hive -v -e "use $dbname;MSCK REPAIR TABLE ${tbname};"
        echo "use $dbname;INVALIDATE METADATA ${dbname}.${tbname};"
        impala-shell -q "use $dbname;INVALIDATE METADATA ${dbname}.${tbname};"
		
		echo >&10
		} &
		
		
done
wait
exec 10>&-