3

I'd made a script for launching parallel rsync process:

#! /bin/bash
LIST=$1
DEST_DIR=$2
RSYNC_OPTS=$3
#echo "rsyncing From=$SRC_DIR To=$DEST_DIR RSYNC_OPTS=$RSYNC_OPTS"
echo $LIST|xargs -n1 -d, echo|xargs -n1 -P 0 -I% rsync --rsync-path='sudo rsync' ${RSYNC_OPTS} % ${DEST_DIR}

Then, I have problems to get the exit status of the rsync process. I know that is possible to get an array of pipestatus, but I need to catch the exit code to know if the rsync was made successfully or not.

migrated from codereview.stackexchange.com Apr 14 '14 at 8:52

This question came from our site for peer programmer code reviews.

2

Do you need to know the exact code or just whether it failed or not?

If you use GNU Parallel instead of xargs you can do:

echo $LIST | parallel -d, -P 0 rsync --rsync-path='sudo rsync' ${RSYNC_OPTS} {} ${DEST_DIR}

When it completes $? will contain how many jobs failed. To get the exact exit code use '--joblog file' to generate a tab separated file including exit code, or use '--halt 1' to get the exit code of the failing rsync in $?.

To learn more:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.