If you ever need to save the history of your Unix shell session, one of the easiest ways to do it is to use the script command, found in most Unix systems.
Simply provide the file name for your log as a command line parameter:
$ script /tmp/unix-session.log
After starting the command, you'll be able to do whatever you want, and once you're done you can use the standard Ctrl+D to end the session recording. The generated log file will have both the commands you have typed during your session and the output generated by these commands.
Your session log with also include the timestamps marking the start and the finish of your recording.
Here's a sample session showing you how you use the script command:
$ script /tmp/unix-session.log Script started, file is /tmp/unix-session.log $ uname -a Linux simplyunix.com 188.8.131.52-xen #3 SMP Sun Oct 15 13:15:34 BST 2006 x86_64 GNU/Linux $ exit Script done, file is /tmp/unix-session.log
Now, if we were to cat the log file generated in this example, we'd see the following:
$ cat /tmp/unix-session.log Script started on Tue Nov 20 16:48:08 2007 $ uname -a Linux simplyunix.com 184.108.40.206-xen #3 SMP Sun Oct 15 13:15:34 BST 2006 x86_64 GNU/Linux $ exit
Script done on Tue Nov 20 16:48:12 2007
Have you got a better way to save your sessions? Let me know! (saving logs from gnome-terminal and Putty doesn't count, mind you!)