Linux history 相关

让history命令保存时间

.bash_profile中加入:

1
export HISTTIMEFORMAT="%d/%m/%y %T "

然后保存退出,运行:

1
$ source ~/.bash_profile

让history实时保存

.bash_profile中加入:

1
2
shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"

然后保存退出,运行:

1
source .bash_profile
坚持技术分享,您的支持将鼓励我继续创作!