Thursday 4 June 2015

Linux "history" command with timestamp

While trying to find out exactly at which time some Linux command ran, the history command can help, especially combined witht the below settings, to get the timestamp also:

 >export HISTTIMEFORMAT="%F %T "
>history 10
 1094  2015-06-04 11:56:32 showsess -a
 1095  2015-06-04 11:56:34 showsess -a
 1096  2015-06-04 11:56:36 cd Log/
 1097  2015-06-04 11:56:37 ll -tr
 1098  2015-06-04 11:58:59 export HISTTIMEFORMAT="%F %T "
 1099  2015-06-04 11:59:02 history -5
 1100  2015-06-04 11:59:05 history 5
 1101  2015-06-04 11:59:14 clear
 1102  2015-06-04 11:59:17 export HISTTIMEFORMAT="%F %T "
 1103  2015-06-04 11:59:20 history 10