Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to solve a common annoyance: when SSH'd into remote servers I often do things that produce a lot more output than I'm expecting. For example, grepping a large log file with a pattern that turns out to be too general. As garbage churns by I sit there hitting ^C and wishing I'd remembered to pipe to less. My best idea so far has been to try to configure my shell to always page output, I asked another question about that. Other than that, I only have less-than-optimal solutions:

  • Wait patiently for the output to finish
  • Train myself to always pipe to less
  • Get a bigger pipe and a faster box so output goes faster

What do you do?

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

Try using screen. http://www.gnu.org/software/screen

You can switch to another shell and continue working on something else while the output completes and has the added advantage that the output will not be sent to your remote link if you are not watching it.

There is also support for buffer scrollback in screen, so you can page or search through the output when it is done.

If you are not using screen, ^C is not responding and you really need to terminate the job, you may want to try '~.' (the default ssh interrupt) to terminate the ssh session. You may need to hit enter before typing '~.'

share|improve this answer
    
I should have added killing my ssh session or switching to another one as one of my sub-optimal solutions. I do run screen but I run it locally, so switching to another shell means logging in again, that's one of the annoyances I'm trying to avoid. These are good suggestions, though. Thanks. –  Ben Williams Jun 26 '09 at 14:13
add comment

Other than the 3 suggestions you've mentioned, you an try ^Z, then just kill the process and fix it.

share|improve this answer
    
Sometimes I've found processes that don't stop with ^C will pause for ^Z –  Rory Jun 30 '09 at 8:50
add comment

Work smarter.. use screen. Pipe to less. Double check the commands you are running.. attention to detail.

Test commands locally if you do have to munge regex foo.

You mention logged in again is a problem, use ssh keys and a key management agent.

share|improve this answer
add comment

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.