how to get exit code when using xargs (parallel) how to get exit code when using xargs (parallel) linux linux

how to get exit code when using xargs (parallel)


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:

  • Have the process that xargs spawns print its exit code and have the parent task parse all the exit code outputs to determine the exit code for each rsync.
  • Use GNU parallel with the --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.