Ubuntu 10.04/GNOME "classic".

How can I log all my "gnome-terminal-related" things?

I mean ex.: I open up 2 gnome-terminal window and ssh to two different servers with them, work a couple of hours, then I close the gnome-terminal's window, then I need these two log files ex.:


So I need each of my GNOME-terminals to be fully logged. So e.g.: when did I gived out a command on a server, etc.

Are there any good methods to fully log a terminal session? Are there any solutions to log menus, eg.: "smitty" from client side?


I don't know what you are trying to achieve, but if you want to account when did you run a certain command you could checkout your shell history and prepend the time it was executed. From man bash:

          If this variable is set and not null, its value is used as a
          format string for strftime(3) to print the time stamp associated
          with each history entry displayed by the  history builtin.  If
          this variable is set, time stamps are written to the history file
          so they may be preserved across shell sessions.  This uses the
          history comment character to dis‐tinguish timestamps from other
          history lines.

If this is not enough for you, you could checkout script. It is a utility that saves everything you type (and it's output) on the shell into a file:

$ script /tmp/shell-output
Script started, file is /tmp/shell-output
$ echo everything is send to /tmp/shell-output, Even ssh sessions started here

EDIT If you want to execute script from ~/.bashrc, you better limit bash to not read you RC file:

$ script -c 'bash --norc' -f /path/to/saved_file
  • history is a bad solution. – LanceBaynes Sep 8 '11 at 1:12
  • If I add: script -f /home/USER/date +%F-%Hh-%Mm-%Ss-%N.txt to the ~/.bashrc file, then why does it keeps starting the "script" endlessly if I open a new terminal?? – LanceBaynes Sep 8 '11 at 1:12
  • script forks to a new shell. .bashrc is processed evey time a new shell is started (bash). If you add this line into .bashrc it will be executed in a forever loop. – Torian Sep 8 '11 at 1:39
  • how to solve this problem?? – LanceBaynes Sep 8 '11 at 1:43
  • 1
    take a look at the answer, I just modified it. – Torian Sep 8 '11 at 1:44

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.