I think that’s an easy question but couldn’t find the solution. I redirect the stdout and stderr of ruby script doing ‘puts’ and sometimes errors (!) to a log file like this :
bundle exec rake import:long_task --trace >& log/import.log &
But it doen’t seem to flush the puts in realtime to the file and when its get an exception it puts the traceback in the top import.log. So, that’s not perfect to debug but it works.
How I can redirect the output of a script in realtime to a file to see exactly what I would have seen if I have launch it directly in the terminal without redirecting ?
Using: Ruby 1.9.2, Rails 3.2, FreeBSD and csh shell.
STDOUT.sync = trueif you don’t want toflushevery time