扣子智能体
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

21 lines
504 B

retry() {
local retries=$1 # number of retries
local wait_time=$2 # waiting time
shift 2
local count=0
cd $(pwd)
until "$@"; do
exit_code=$?
count=$((count + 1))
if [ $count -lt $retries ]; then
echo "Attempt $count/$retries failed with exit code $exit_code. Retrying in $wait_time seconds..."
sleep $wait_time
else
echo "Attempt $count/$retries failed with exit code $exit_code. No more retries left."
return $exit_code
fi
done
return 0
}