e61a23efaaa4baa0c8060e6a332f6b94f3b96bca jcasper Fri Apr 21 09:01:34 2023 -0700 The -I and -n flags conflict; keeping the one we want. No ticket diff --git src/product/scripts/fetchCramReference.sh src/product/scripts/fetchCramReference.sh index ed36df3..8be069c 100755 --- src/product/scripts/fetchCramReference.sh +++ src/product/scripts/fetchCramReference.sh @@ -53,47 +53,47 @@ then echo "Error: $ERRORDIR is missing or not a directory" exit 255 fi ( flock -n 9 || exit 0 # set up cleanup in the event of Ctrl-C trap '{rm -f "${PENDING}/*.out"; rm -f ${PENDING}/fetch.lock; exit 1; }' INT # Re-add files that previously failed, if they failed long enough ago. # Retry after 1 hour; give up after $MAXTRIES attempts find ${ERRORDIR} -type f -mmin +60 -printf "%f\0" | - xargs -0 -n 1 -I % sh -c \ + xargs -0 -I % sh -c \ ' if [ -e "${PENDING}/%.try${MAXTRIES}" ] then rm -f "${PENDING}/%.try${MAXTRIES}" "${ERRORDIR}/%" else cp $(find "${PENDING}" -maxdepth 1 -type f -name "%.try*" -print -quit) "${PENDING}/%" || true rm -f "${ERRORDIR}/%" fi ' # Fetch files in parallel; up to 5 at a time. If xargs does not support -P 5 # in your Unix, delete that option to do serial fetch. ls "$PENDING" | (egrep -v 'fetch.lock|.out|.try' || true) | -xargs -I % -n 1 -P 5 sh -c \ +xargs -I % -P 5 sh -c \ ' if WGETOUT=$(wget -nv -i "${PENDING}/%" -O "${PENDING}/%.out" 2>&1) then # Download successful mv "${PENDING}/%.out" "${DESTDIR}/%" && rm -f "${PENDING}/%" "${PENDING}/%.try*" || echo "Internal server error: Please contact system administrator" > ${ERRORDIR}/% else # Download failed, record wget error message echo "$WGETOUT" | tr "\n" "\t" > "${ERRORDIR}/%" fi # On error, increment try count if [ -e "${ERRORDIR}/%" ] then OLDTRY=$(find "${PENDING}" -maxdepth 1 -type f -name "%.try*" -print -quit)