Created
July 1, 2021 14:35
-
-
Save kougazhang/cdaf76293e2520bc92e297505ae3d82c to your computer and use it in GitHub Desktop.
shell 使用 xargs 执行并发 #shell #redis
This file contains hidden or 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
#!/bin/bash | |
providers=("jingdong") | |
project=/home/filex/download | |
etc=$project/etc | |
cfg=$project/cfg | |
log=$project/log/$(date "+%Y-%m-%d_%H-%M-%S") | |
parallism=8 | |
echo "start to check missing log time point" | |
for provider in "${providers[@]}"; do | |
$project/check_missing.sh $cfg/$provider.sh | |
done | |
echo "start to download logs" | |
function download() { | |
$project/download --info=$1 --cfg=$2 --provider=$3 | |
if [ $? -eq 0 ]; then | |
redis-cli srem missing_$3 $1 | |
fi | |
} | |
export -f download | |
export project | |
for provider in "${providers[@]}"; do | |
(redis-cli --eval $project/sscan.lua missing_$provider 10 | xargs -n1 -I{} -P $parallism bash -c "download {} $etc/$provider.json $provider") & | |
done | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment