View previous topic :: View next topic |
Author |
Message |
Jarli n00b
Joined: 22 Mar 2012 Posts: 8
|
Posted: Wed Nov 14, 2012 3:54 pm Post subject: Command History |
|
|
Is there anyway to determine when a command was run on Gentoo, through a terminal session?
I know the 'history' command shows the list of commands, but I would like to see if there is a time stamp. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9645 Location: almost Mile High in the USA
|
Posted: Wed Nov 14, 2012 4:43 pm Post subject: |
|
|
This link got me
http: //larsmichelsen.com/open-source/bash-timestamp-in-bash-history/
This assumes that you're using bash. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Wed Nov 14, 2012 4:50 pm Post subject: |
|
|
Moved from Gentoo Chat to Portage & Programming as it's not about Gentoo itself.
As the link that eccerr0r posted shows you need to set HISTTIMEFORMAT, assuming you're using bash. Obviously this will only show you the timestamp after you've set it, for commands before that it will just use the current time which is then cached. _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Wed Nov 14, 2012 7:10 pm Post subject: |
|
|
Jarli ...
zsh timestamps (with 'shopt extended_history' set) ... the history file can then be parsed with the following:
Code: | # perl -lne 'm#: (\d+):\d+;(.+)# && printf "%s :: %s\n",scalar localtime $1,$2' $HISTFILE |
I'm not sure if bash timestamps are constructed in a similar manner but is should be parsable none the less with a similar oneliner.
best ... khay |
|
Back to top |
|
|
|