How do log every thing printed on the terminal

Sometimes we just keep working on a terminal and get lost what all we did.
Isn’t it good if we can get some kind of logs which can give us all steps we followed.

First thing which comes in mind is the “history” command, but that will not give the standard outputs which we got after running the commands.

So, here is the solution.Use a command called “script”.

e.g.

$ script standard_out.txt
Script started, file is standard_out.txt
$ date
Mon Sep 8 07:57:20 IST 2008
$ asdf
bash: asdf: command not found
$ exit
Script done, file is standard_out.txt

To exit you need to press “ctrl+D”.

Now lets check the content of “standard_out.txt” file.

$ cat standard_out.txt
Script started on Mon 08 Sep 2008 07:57:10 AM IST
$ date
Mon Sep 8 07:57:20 IST 2008
$ asdf
bash: asdf: command not found
$ exit
Script done on Mon 08 Sep 2008 07:57:38 AM IST

For more information look at the man page of ”script”‘.

17. September 2008 by Neependra
Categories: Uncategorized | Tags: | Leave a comment

Leave a Reply