I am processing a text file with multiple parallel processes spawned by xargs. I also need to capture the stdout from each process into a separate log file. Below is an example where the output from each process is interleaved into a single file -- not what I want.
Ideally, each logfile should be numbered by the file line number, that is, logfile-1, logfile-2, etc.
cat inputfile.txt | xargs -n 1 -P 8 ./myScript.sh | tee logfile
It would be nice to avoid an external wrapper script if possible, but if there is a way to wrap myScript with a here document, that would work.
exec > logfile-$$
or some such? Basically the script controls its logging rather thanxargs
attempting it. – Decanter