Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

logfile-2011-09-08-10-00-02.txt
logfile-2011-09-08-10-00-04.txt

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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:

   HISTTIMEFORMAT
          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
share|improve this answer
    
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
show 1 more 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.