Linux查看History记录加时间戳小技巧
来源:互联网 发布:成都盘古网络离职 编辑:程序博客网 时间:2024/06/06 18:29
- Linux查看History记录加时间戳小技巧
- 熟悉bash的都一定知道使用history可以输出你曾经输入过的历史命令,例如
- [root@servyou_web ~]# history | more
- 6 ./test.sh
- 7 vim test.sh
- 8 ./test.sh
- 但是这里只显示了命令,并没有显示执行命令的时间,因为保存历史命令的~/.bash_history里并没有保存时间。
- 通过设置环境变量 export HISTTIMEFORMAT="%F %T `whoami` " 给history加上时间戳
- [root@servyou_web ~]# export HISTTIMEFORMAT="%F %T `whoami` "
- [root@servyou_web ~]# history | tail
- 1014 2011-06-22 19:17:29 root 15 2011-06-22 19:13:02 root ./test.sh
- 1015 2011-06-22 19:17:29 root 16 2011-06-22 19:13:02 root vim test.sh
- 1016 2011-06-22 19:17:29 root 17 2011-06-22 19:13:02 root ./test.sh
- 1017 2011-06-22 19:17:29 root 18 2011-06-22 19:13:02 root vim test.sh
- 1018 2011-06-22 19:17:29 root 19 2011-06-22 19:13:02 root ./test.sh
- 1019 2011-06-22 19:17:29 root 20 2011-06-22 19:13:02 root vim test.sh
- 1020 2011-06-22 19:17:29 root 21 2011-06-22 19:13:02 root ./test.sh
- 1021 2011-06-22 19:17:29 root 22 2011-06-22 19:13:02 root vim test.sh
- 1022 2011-06-22 19:25:22 root 22 2011-06-22 19:13:02 root vim test.sh
- 1023 2011-06-22 19:25:28 root history | tail
- 可以看到,历史命令的时间戳已经加上了,但是.bash_history里并没有加上这个时间戳。其实这个时间记录是保存在当前shell进程内存里的,如果你logout并且重新登录的话会发现你上次登录时执行的那些命令的时间戳都为同一个值,即当时logout时的时间。
- 尽管如此,对于加上screen的bash来说,这个时间戳仍然可以长时间有效的,毕竟只要你的server不重启,screen就不会退出,因而这些时间就能长时间保留。你也可以使用echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile 然后source一下就OK
0 0
- Linux查看History记录加时间戳小技巧
- Linux查看History记录加时间戳小技巧
- Linux查看History记录加时间戳小技巧
- Linux查看History记录加时间戳小技巧
- Linux查看History记录加时间
- linux history记录加时间戳
- Linux History记录加时间戳实用技巧
- Linux 给history加时间戳
- 为history加时间戳
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux命令——history查看用户操作记录及时间
- Linux 查看history的操作时间
- linux history 记录 时间 ip 登录用户
- Linux history 命令记录加执行时间戳以及记录到日志
- linux中history的小技巧
- history查看历史操作记录,并显示操作时间
- 关于MPMoviePlayerController以及MPMoviePlayerViewControlle流媒体视频播放
- Android 按钮类控件大集锦:Button ToggleButton CheckBox RadioButton
- 紫外线杀菌装置:过流式Photoscience紫外线杀菌器
- 总结一下近半个月的题目。
- android在打开activity时如何防止edittext获取焦点弹出软键盘
- Linux查看History记录加时间戳小技巧
- logistic函数,sigma函数性质
- [思路] hdu 4811 Ball
- matlab加载HFSS生成的S参数
- 向量代数:向量加法、共线与共面
- Python的招牌菜xmlrpc
- sql语句性能优化介绍 .
- 峰值速率与用户速率
- HashSet vs. TreeSet vs. LinkedHashSet