1、使用history有时间戳#vim /etc/profile.d/history.sh
export HISTTIMEFORMAT="%F %T `whoami` "
# source /etc/profile.d/history.sh
2、查看结果# history
1015 2017-07-28 13:18:28 root history
1016 2017-07-28 13:54:33 root
1017 2017-07-28 13:56:06 root who am i
1018 2017-07-28 13:56:18 root whoami
1019 2017-07-28 13:57:26 root ls
1020 2017-07-28 13:57:34 root vim /etc/profile.d/
1021 2017-07-28 13:57:43 root cd /etc/profile.d/
1022 2017-07-28 13:57:43 root ls
1023 2017-07-28 13:57:51 root vim history.sh
1024 2017-07-28 13:58:09 root source history.sh
1025 2017-07-28 13:58:12 root history