Exit tail when other process is done

tail

I have

parallel --j 2 -- "sh script1" "sh script2"

where script1 and script2 log in files log1 and log2

I would like to change this to:

parallel --j 3 -- "sh script1" "sh script2" "tail -f log1 log2"

The reason to use tail is when I allow the two scripts to output on the screen at the same time – the output becomes a mess and I lose the cursor etc issues – I need to restart the terminal almost after every execution.

The problem though is that now this will go forever and I would like tail to exit when script1 and script2 are done. How I can do that?

Best Answer

This may also not be what you want, but how about:

parallel --j 2 -- "sh script1" "sh script2"; tail log1 log2

Once both jobs are done, you get the non-waiting tail of both log files.

Related Question