Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am running a rather complex python script in Ubuntu 12.10 for the last seven days. It must have generated atleast 20k lines of output on the terminal till now but not all of it is visible.

I didn't have the foresight to enable unlimited scrolling on the terminal neither did I try something like saving the output to some file. But now I am running out of time and I just can't think of rerunning the entire code again and try such options.

Does anyone know how can I see the complete output now without having to rerun the script?

Many Thanks

share|improve this question

2 Answers 2

You can not. What goes outside the buffer is gone.


By the way... the smarter option would be to send that output to a logfile.

python script.py >/tmp/output.txt 2>&1

will send all output to /tmp/output.txt. If you open a 2nd TAB and do

tail -f /tmp/output.txt

you can see the log on screen and retain the information.


Also works:

python script.py | tee output.txt

or

python script.py 2>&1 | tee output.txt
share|improve this answer
1  
To avoid the tailf step, you can also use the tee program: python script.py | tee output.txt. Note that some output might be logged to stderr instead of stdout. If you wish to retain this by merging it with the standard output, use python script.py >output.txt 2>&1 or python script.py 2>&1 | tee output.txt. If is well-behaved, you can also pause execution of a program in bash by pressing Ctrl+Z. To resume execution, execute the fg command. Use the bg command to continue execution in the background. –  Lekensteyn Oct 1 '13 at 11:59
    
@Lekensteyn thanks. I always forget about tee :P –  Rinzwind Oct 1 '13 at 12:41
    
another option: script -a all_output.log and then inside that script session run the program. Once the prog finishes, exit the script session with : exit (or Ctrl+d at the begining of the prompt). Then you can do show a page-per-page "replay" with: more -v all_output.log. Another (even better) option: use screen, turn on its log saving, and inside it start the program. screen has the benefit of allowing you to disconnect+reconnect to the session! (Ie, you detach from screen (ctrl+A d) and let it run the shell and prog in the server, and you can reconnect to it later) –  Olivier Dulac Oct 1 '13 at 15:36

Open your terminal and go to Profile Settings>Scrollbar and there is an option to set it to unlimited. I don't know whether it would save all 20k lines. Or else try the solution from Rinzwind.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.