Add TimeStamp to command History

Nitiphone

New Member
Credits
27
Please kindly help me add date time on history command.

I tried but not work on
1. login root
2. vi /etc/bashrc
#add below command
export HISTTIMEFORMAT='%F %T '

# su - [user]

# echo $HISTTIMEFORMAT

source /etc/bashrc
*****
It can work on time but when I log out and login again. it go back to normal need to run source /etc/bashrc to active the Timestamp again

[[email protected] ~]# cat /etc/*release
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Red Hat Enterprise Linux Server release 6.6 (Santiago)
Red Hat Enterprise Linux Server release 6.6 (Santiago)
[[email protected] ~]#
 


Tolkem

Well-Known Member
Credits
1,824
Please kindly help me add date time on history command.
1. Add this to your .bash_profile file
Code:
export HISTTIMEFORMAT="%d/%m/%y %T
2. Open a terminal and type
Code:
. .bash_profile
note the dot preceding the .bash_profile line and be sure to use it and hit Enter.

3. Try the history command again and see if it worked.

Hope this helps! :)
 

flavio

New Member
Credits
70
Please kindly help me add date time on history command.

I tried but not work on
1. login root
2. vi /etc/bashrc
#add below command
export HISTTIMEFORMAT='%F %T '

# su - [user]

# echo $HISTTIMEFORMAT

source /etc/bashrc
*****
It can work on time but when I log out and login again. it go back to normal need to run source /etc/bashrc to active the Timestamp again

[[email protected] ~]# cat /etc/*release
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Red Hat Enterprise Linux Server release 6.6 (Santiago)
Red Hat Enterprise Linux Server release 6.6 (Santiago)
[[email protected] ~]#
I use this, both for user ($) and root (#)

Code:
$ / # echo 'export HISTTIMEFORMAT="%F_H-%M-%S "' >> ~/.bashrc
$ / # source ~/.bash_profile
The 2nd command may be replaced by just close and open Terminal again.
 

Nitiphone

New Member
Credits
27
I tried but some server work but some server not work, Can you guide me a little more?
This Server not work
pcrfocf105$ history | head -1
11 tail -f PCRF5.ES07.GGSN.0_20191004.stat|egrep "DMPRecvMessageCountTPS=|DMPBusyMessageCountTPS="
pcrfocf105$ echo 'export HISTTIMEFORMAT="%F %H:%M:%S "' >> ~/.bashrc
pcrfocf105$ source ~/.bash_profile
pcrfocf105$ history | head -1
14 less PCRF5.ES07.GGSN.0_20191004.stat
pcrfocf105$

This Server Work
[[email protected] ~]$echo 'export HISTTIMEFORMAT="%F %H:%M:%S "' >> ~/.bashrc
[[email protected] ~]$source ~/.bash_profile
[[email protected] ~]$history | head -10
4 2020-08-04 09:44:01 /opt/damocles/sbin/D20CTL db backup -f /opt/damocles/conf/D20_C000_LTC03.yaml
5 2020-08-04 09:44:01 ll
6 2020-08-04 09:44:01 rm -r backup-D20_C000_LTC03-2018-12-11T17\:36\:02+07\:00/
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
6,153
Sorry, I can't guide you in server matters, I just remembered the article. :confused:
 


Members online


Top