[olug] Hint: Use 'screen' and 'script' to keep track of long-running programs.

Daniel Linder dan at linder.org
Sun Feb 1 04:30:35 UTC 2004


Thought I'd post a hint that others might find useful.

>From the 'script' manpage:
  script - make typescript of terminal session

Often when I am trying to get something setup, or I know I will be making
a lot of changes to the system, I like to keep some sort of log of what I
do.  Rather than relying on "history" to tell me (it won't help if you ssh
over to another machine, nor will it help with seeing exactly what you
changed in a file using 'vi'), I commonly kick off 'script' before
starting to work.

Try this: At a command line, run the "script" command.  Script replys with "
Script started, file is typescript".  Now, type in a couple commands, even
go into "vi".  When you are done, type "exit" at your prompt and script
will reply with "Script done, file is typescript".

Now, use "vi" to edit the file "typescript".  If you look carefully, you
will see everything that got sent to the screen during this session.  If
you see a lot of "^[[" characters, those are the control codes being sent
to your screen that move the cursro, clear the screen, change colors, etc.
 In some cases, it is possible to replay this file back to your screen and
see your session as you typed it.  If you later have to document what
exactly you did, you just need to reference the typescript file and update
your documentation.

The second command is 'screen'.  Again, from the manpage:
  screen - screen manager with VT100/ANSI terminal emulation

Screen is a great way to have multiple windows open even if you are
physically restricted to a single window (i.e. you're dialing in to your
server from a relatives house over vacation).  Screen also has the added
feature that you can detach the screen sessions, logoff, and come back
later and re-attach and pick up where you left off.

I use this feature when I am doing sensitive work remotely and don't want
to take the chance that killing my connection will kill the program --
system updates, kernel compiles, large downloads, etc.  As long as the
screen command is kept running, your system prompt will still be there.

Hope you take some time to check into them and see if they provide a
solution you have or didn't realized you needed! ;)

Dan


More information about the OLUG mailing list