Dumping a Linux console scrollback buffer?

Posted by Gerald Combs on Server Fault See other posts from Server Fault or by Gerald Combs
Published on 2010-03-11T17:10:07Z Indexed on 2010/03/11 17:20 UTC
Read the original article Hit count: 410

Filed under:
|

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
Repeat:
  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.

© Server Fault or respective owner

Related posts about linux

Related posts about console