CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   mpirun--> output be written in both Log file and Terminal (

maysmech January 19, 2011 13:18

mpirun--> output be written in both Log file and Terminal

How can i use parallel run and have output not only in log file, also in terminal window.

Only in log file:

mpirun -np 8 icoFoam -parallel > log &
Only in terminal:

mpirun -np 8 icoFoam -parallel

cnsidero January 19, 2011 13:31

Option 1) Try 'tee'. E.g.


mpirun -np 8 icoFoam -parallel | tee log
Check the man pages for 'tee'

Option 2) Redirect the output to a log file like for your first command:


mpirun -np 8 icoFoam -parallel  > log &
and then use the -f with 'tail' to view log file dynamically:


tail -f log
Option 3) Use screen:

Open an new screen:


Launch your job:


mpirun -np 8 icoFoam -parallel
Detach your screen: CTRL+A+D

Reattach your screen to view your running job later:


screen -r
I prefer #2 if I'm running on a local workstation and #3 if I'm running remotely. 'screen' is the most flexible and powerful method - I would suggest spending some time to learn how to use 'screen'. Look in the man pages or check the web.

l_r_mcglashan January 19, 2011 13:37

Isn't dumping it all to both screen AND file a bit unnecessary? Why not output it to log and use 'tail log' to look at the log file? Or if you're interested in looking at residuals use foamLog / pyFoam.

maysmech January 19, 2011 15:30

Thanks, i will try to do your suggestions.

vitormoura June 22, 2017 23:31

I was lurking and saw this thread. I got a solution that might help others (since the post is old).
On a second terminal, use this command:


watch -n(secondsinterval) tail -n(numberoflines) logfile
someone gave me that tip to avoid excess of process on simulation.

All times are GMT -4. The time now is 03:29.