让history记录命令的历史执行时间

2023-05-16

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

history记录命令的历史执行时间

由于Linux默认的history记录仅保存了命令的内容,

[root@oracle ~]# history           

    1  date -s "2013-1-22 9:48:30'

    2  "

    3  date -s "2013-1-22 9:48:30"

    4  clock -w

    5  clear

    6  ntpdate 10.20.0.11

    7  setup

    8  service iptabels stop

没有具体的时间,我只能通过查出用户的登录与退出的时间,来给他们一个时间范围。

因此,我们非常有必要对history历史命令的记录功能进行优化,我推荐的参数如下:

编辑/etc/bashrc

添加以下配置信息:

# 设置保存历史命令的文件大小

export HISTFILESIZE=1000000000

# 保存历史命令条数 export HISTSIZE=1000000

# 实时记录历史命令,默认只有在用户退出之后才会统一记录,很容易造成多个用户间的相互覆盖。

export PROMPT_COMMAND="history -a"

# 记录每条历史命令的执行时间

export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S "

 

使更改立即生效:

# source /etc/bashrc

查看历史命令记录:

# history

[root@oracle ~]# source /etc/bashrc

[root@oracle ~]# history

    1  2013-01-22_14:42:36 date -s "2013-1-22 9:48:30'

    2  2013-01-22_14:42:36 "

    3  2013-01-22_14:42:36 date -s "2013-1-22 9:48:30"

    4  2013-01-22_14:42:36 clock -w

 

本文出自 “xmshuiyong’blog” 博客,请务必保留此出处http://xmshuiyong.blog.51cto.com/1980172/1123979

转载于:https://my.oschina.net/xxjbs001/blog/286607

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

让history记录命令的历史执行时间 的相关文章

随机推荐

  • Python3 easyinstall error

    When installing some supported packages in python3 2 2 usually got a error cannot remember clearly but like array object
  • boost learn notes

    lt xml version 61 34 1 0 34 encoding 61 34 utf 8 34 gt boost learn notes boost learn notes Documents http www boost org
  • SQL Server DBA常见面试 笔试问题

    很多开发人员都想成为一名DBA xff0c 也有很多人一开始就把自己定位成为一名DBA xff0c DBA究竟需要掌握些什么知识和技能呢 以下是我做DBA工作和面试DBA时 xff0c 整理的一些DBA方面的三十个问题 xff0c 三十个大
  • 用MTR诊断网络问题

    网络诊断背景安装MTR LinuxWindows苹果系统生成MTR报告 在基于Unix的系统上使用MTR在Windows系统上使用MTR阅读MTR报告分析MTR报告 验证数据包丢失网络延迟通用MTR报告 目标主机网络配置不正确住宅或商业路由
  • Rhino Mock

    mock interfaces delegates and classes including those with parameterized constructors set expectations on the called met
  • Url重写

    例如 xff1a http www baidu com view aspx id 61 1 和http www baidu com view 1 aspx 访问的页面相同 只需要全局应用程序类的Application BeginReques
  • [置顶] C# 邮件发送方法【NetMail方式】

    在上一篇博文C 邮件发送方法 webMail方式 中介绍了Webmail的邮件发送方式 xff0c 现在介绍下C 中使用NetMail发送邮件的方式 xff0c 测试代码如下 xff1a lt summary gt NetMail方式测试通
  • 用py2exe打包后的程序一闪而过

    最近用python写了个小工具 xff0c share给同事使用 xff0c 但是在测试的时候发现点完exe文件 xff0c 就一闪而过 不知道发生了什么查询了伟大的谷歌 xff0c 发现只要在结尾加上 os system 39 pause
  • WebView显示的网页在大分辨率屏下被放大--解决方案

    例如适合800px宽度的页面 xff0c 如果通过WebView在1024px的屏幕宽度下显示时 xff0c 内容 图片 会被放大 xff0c 整体页面会超出屏幕 试了将WebView的settings中的缩放都关闭了也不行 后来发现了We
  • ExtJs TreePanel 不能加载ashx数据的解决办法

    今天学习Extjs TreePanel 时在加载动态数据时经常加载不进来 xff0c 因为我是使用MVC2获取动态数据的 xff0c 单独调试MVC的返回数据时OK的 xff0c 网上有很多解决方案 xff0c 其中最简单的是 xff1a
  • 信息树和XML文件的遍历及XML文件的应用

    function Save 将INfomationTree中的不是Http开头的组 xff0c 保存到本地 xff0c 然后再从本地上传到服务器端 var IInformationTree 61 document parentWindow
  • chapter 4: A literature review(re-read papers to gain fresh understanding)

    chapter 4 A literature review re read papers to gain fresh understanding 1 Writing for Science and Engineering Papers Pr
  • Connect to a Windows PC from Ubuntu via Remote Desktop Connection

    http www 7tutorials com connecting windows remote desktop ubuntu A useful feature of Windows is being able to connect to
  • HTTP MIME type

    扩展名 类型 子类型 IIS 4 0 IIS 5 0 application octet stream 是 是 323 text h323 否 是 acx application internet property stream 否 是 a
  • [资源分享]Linode免费使用 [ 资源分享 ]

    Linode 是目前最优秀的 VPS 服务提供商 最近 xff0c Linode 推出了一种全新的 Linode 帐户注册方式 xff0c 该方式允许用户试用 Linode VPS 4个小时的时间而不需要输入付款信息 xff08 只要有邮箱
  • iOS9 Search API 之 Spotlight

    iOS9以后 有三种api提供搜搜方式 加强引导用户关注 我们的app及相关内容的方式 NSUserActivity Web Markup Core Spotlight 用法 前两种 实战操作性不够强 后续补充 这里先讲 spotlight
  • AngularJS优缺点、使用场景

    AngularJS 优缺点 优点 xff1a AngularJS模板功能强大丰富 xff0c 自带了极其丰富的angular指令 AngularJS是完全可扩展的 xff0c 与其他库的兼容效果很好 xff0c 每一个功能可以修改或更换 x
  • 面试准备

    首行占位 Python相关 1 Python3特性和变化 1 Python3默认编码是UTF 8 xff0c 2为ASCII 2 Python3中只有int xff0c 2中有int跟long xff0c 其中int不能超过sys maxi
  • matlab练习程序(地图上画经纬度)

    需要看下生成的数据在地球上的经纬度具体位置 投影为墨卡托投影 clear all close all clc load coast a 61 load 39 out txt 39 自己的经纬度数据 axesm mercator plotm
  • 让history记录命令的历史执行时间

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 让 history记录命令的历史执行时间 由于 Linux默认的 history记录仅保存了命令的内容 xff0c root 64 oracle history 1 dat