We would like to save the output of a program run on a Linux console which spans many lines. Unfortunately it wasn't logged or run under screen, or any other way that lets us easily capture the output. The best method we've been able to come up with so far is:

Log into the machine via a separate SSH session
In the console session, page to the top of the buffer
  In the SSH session, run "cat /dev/vcs >> screendump.txt"
  In the console session, page down one screen
Dump the final screen in the SSH session

Is there a better way? It seems like if the VC memory were contiguous and you knew where it was you could use dd to pull the console text directly out of kernel memory and into a file.


setterm can dump the contents of a Linux virtual console:

setterm -file log.txt -dump [ttynumbers]

However, it does not have access to the scrollback buffer, only to what's currently displayed.

| improve this answer | |

Unless VGACON_SOFT_SCROLLBACK is set to "Y", the scrollback buffer is in VGA memory rather than system memory.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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