Centos History 命令历史记录添加执行时间

Centos History 命令历史记录添加执行时间

在/etc/profile尾部加入以下环境变量

export HISTTIMEFORMAT=‘%F %T‘

Centos  History 命令历史记录添加执行时间

执行环境变量生效

source /etc/profile

测试结果

[ network-scripts]# history 
 2019-12-06 13:57:01  free -m
 2019-12-06 13:57:32  cat /proc/cpuinfo 
 2019-12-06 13:57:39  top
 2019-12-06 13:58:19  ll
 2019-12-06 13:58:27  cd /etc/sysconfig/network-scripts/
 2019-12-06 13:58:27  ls
 2019-12-06 13:58:28  ll
 2019-12-06 13:58:41  ip addr
 2019-12-06 13:58:46  vim ifcfg-em1 
 2019-12-06 13:58:51  yum install vim -y
 2019-12-06 14:01:23  history 
 2019-12-06 14:04:15  vim /etc/profile
 2019-12-06 14:04:48  source /etc/profile
 2019-12-06 14:04:50  history 
 2019-12-06 14:05:13  vim /etc/profile
 2019-12-06 14:05:22  source /etc/profile
 2019-12-06 14:05:23  history 
[ network-scripts]# 
# 命令的间隔可以在定义环境变量时自已调整

相关推荐