Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2547691
  • 博文数量: 271
  • 博客积分: 6659
  • 博客等级: 准将
  • 技术积分: 3141
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-17 10:24
文章分类

全部博文(271)

文章存档

2016年(2)

2015年(12)

2014年(7)

2013年(19)

2012年(22)

2011年(81)

2010年(128)

分类: LINUX

2011-03-17 13:32:49

history命令显示时间记录

查了半天系统环境变量HISTTIMEFORMAT 丝毫不见踪迹 原来在bash man中才有收录


#man bash

 

       HISTTIMEFORMAT
        If  this  variable is set and not null, its value is used as a format string for strftime(3) to print the time stamp associated with each history entry displayed by the history builtin.  If this variable is set, time stamps are written to the history file so they  may  be  preserved  across  shell sessions.

1.如果这个变量被设置,且不为空,使用它的值作为格式字符串strftime(3)打印时间戳与历史命令内建显示的每个条目相关联的历史.如果这个变量被设置,时间戳会被写入历史文件,这样的话他们可能会保留在shell会话。

 


查看HISTTIMEFORMAT 具体参数 
#man strftime

取了两条记录
%F     Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
%T     The time in 24-hour notation (%H:%M:%S). (SU)

[root@jerome-1 conf]# HISTTIMEFORMAT="%F %T "


常用到的一些显示方式

下面这条相当于上面的方式
[root@jerome-1 conf]# HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
[root@jerome-1 conf]# history | tail                    
 1091  2011-03-17 12:57:57 history

 

可将以下两条加入到/etc/profile文件当中
export  HISTTIMEFORMAT="%F %T "

 

阅读(7732) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~