history命令优化:
有时发现运行中设备重启,但设备被ssh的人较多,无法确定设备是否是被人为的在reboot,通过修改history命令配置可以追查此问题,方便以后运维。可在iraid的镜像里做同样修改。
好处:
a、让历史记录里面带有时间
b、让同一设备所有连接终端命令都记录到history当中去。
效果如下:
方法:在/etc/bashrc 最后加下下面内容然后再source /etc/bashrc
HISTTIMEFORMAT="%F %T "
export HISTTIMEFORMAT
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# After each command, append to the history file and reread it
export PROMPT_COMMAND=“KaTeX parse error: Expected '}', got 'EOF' at end of input: …ROMPT_COMMAND:+PROMPT_COMMAND$’\n’}history -a; history -c; history -r”
export HISTSIZE=10000