On 03/30/2012 11:12 AM, Tim Prince wrote:
> On 03/30/2012 10:41 AM, tyler.balson_at_[hidden] wrote:
>> I am using the command mpirun -np nprocs -machinefile machines.arch
>> Pcrystal and my output strolls across my terminal I would like to
>> send this output to a file and I cannot figure out how to do so....I
>> have tried the general > FILENAME and > log & ....these generate
>> files however they are empty.....any help would be appreciated.
If you see the output on your screen, but it's not being redirected to a
file, it must be printing to STDERR and not STDOUT. The '>' by itself
redirects STDOUT only, so it doesn't redirect error messages. To
redirect STDERR, you can use '2>', which says redirect filehandle # 2,
which is stderr.
some_command 2> myerror.log
some_command >myoutput.log 2>myerror.log
To redirect both STDOUT and STDERR to the same place, use the syntax
"2>&1" to tie STDERR to STDOUT:
some_command > myoutput.log 2>&1
I prefer to see the ouput on the screen at the same time I write it to a
file. That way, if the command hangs for some reason, I know it
immediately. I find the 'tee' command priceless for this:
some_command 2>&1 | tee myoutput.log
Google for 'bash output redirection' and you'll find many helpful pages
with better explanation and examples, like this one:
If you don't you bash, those results will be much less helpful.
I hope that helps, or at least gets you pointed in the right direction.
> If you run under screen your terminal output should be collected in
> screenlog. Beats me why some sysadmins don't see fit to install screen.