I have a linux program(the language doesn’t matter) which prints it’s log onto stdout.
The log IS needed for monitoring of the process.
Now I’m going to parallelize it by fork’ing or using threads.
The problem: resulting stdout will contain unreadable mix of unrelated lines…
And finally The question: How would you re-construct the output logic for parallel processes ?
Sorry for answering myself…
The definite solution was to use the GNU parallel utility.
It came to replace the well known
xargsutility, but runs the commands in parallel, separating the output into groups.So I just left my simple one-process, one-thread utility as-is and piped its call through the
parallellike that:This, depending on parallel’s options can produce nicely grouped outputs for multiple calls of
my-utility