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.
Anyone knows?
-x, --exit Exit if the size (see the -s option) is exceeded. --help Print a summary of the options to xargs and exit. --version Print the version number of xargs and exit. The options --max-lines (-L, -l), --replace (-I, -i) and --max- args (-n) are mutually exclusive.
xargs will run the first two commands in parallel, and then whenever one of them terminates, it will start another one, until the entire job is done. The same idea can be generalized to as many processors as you have handy. It also generalizes to other resources besides processors.
The xargs command builds and executes commands provided through the standard input. It takes the input and converts it into a command argument for another command. This feature is particularly useful in file management, where xargs is used in combination with rm , cp , mkdir , and other similar commands.
If no command is specified, xargs executes echo by default. You many also instruct it to read data from a file instead of stdin.
The man page for xargs shows the possible exit status values, however it can only produce a single aggregated exit code, not an exit code per child that it runs. You could try one of these options:
--joblog
option. This will create a file containing all the commands which were run in parallel along with its exit code and other information. This file could then be parsed after parallel
exits to determine which rsync commands failed and their respective error codes.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With