Showing posts with label save every command in linux. Show all posts
Showing posts with label save every command in linux. Show all posts

Friday, May 3, 2013

Script Saving every command and its output as log in Linux


script Saving every command and its output in log in Linux

[root@test ~]# script tester.log
Script started, file is tester.log
[root@test ~]# ping google.com
PING google.com (74.125.236.73) 56(84) bytes of data.
64 bytes from maa03s05-in-f9.1e100.net (74.125.236.73): icmp_seq=1 ttl=57 time=30.8 ms
64 bytes from maa03s05-in-f9.1e100.net (74.125.236.73): icmp_seq=2 ttl=57 time=31.4 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1243ms
rtt min/avg/max/mdev = 30.876/31.165/31.454/0.289 ms
[root@test ~]# cal
     March 2013
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
[root@test ~]# date
Fri Mar  1 20:11:40 IST 2013
[root@gai-1552 ~]# echo " Test Done sucessfully"
 Test Done sucessfully
[root@test ~]# exit
exit
Script done, file is tester.log
[root@test ~]#


Now the output is

[root@test ~]# cat tester.log
Script started on Fri 01 Mar 2013 08:10:52 PM IST
[root@test ~]# ping google.com
PING google.com (74.125.236.73) 56(84) bytes of data.
64 bytes from maa03s05-in-f9.1e100.net (74.125.236.73): icmp_seq=1 ttl=57 time=30.8 ms
64 bytes from maa03s05-in-f9.1e100.net (74.125.236.73): icmp_seq=2 ttl=57 time=31.4 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1243ms
rtt min/avg/max/mdev = 30.876/31.165/31.454/0.289 ms
[root@test ~]# cal
     March 2013
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
[root@test ~]# date
Fri Mar  1 20:11:40 IST 2013
[root@gai-1552 ~]# echo " Test Done sucessfully"
 Test Done sucessfully
[root@test ~]# exit
exit

Script done on Fri 01 Mar 2013 08:12:04 PM IST