Tips for viewing History records and adding timestamps in Linux Anyone familiar with bash must know that you can use history to output the historical commands you have entered, for example [root@servyou_web ~]# history | more 6./test.sh 7 vim test.sh 8./test.sh However, only the command is displayed here, and the time when the command was executed is not displayed, because the time is not saved in Add timestamp to history by setting environment variable [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 As you can see, the timestamp of the historical commands has been added, but this timestamp has not been added to .bash_history. In fact, this time record is saved in the memory of the current shell process. If you log out and log in again, you will find that the timestamps of the commands executed when you last logged in are all the same value, that is, the time when you logged out. Nevertheless, for bash with screen, this timestamp can still be valid for a long time. After all, as long as your server is not restarted, screen will not exit, so these times can be retained for a long time. You can also use Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Detailed tutorial on installing Mysql5.7.19 on Centos7 under Linux
>>: Summary of Problems in Installing MySQL 5.7.19 under Linux
MySQL full text search Chinese solution Recently,...
After installing the latest version 8.0.11 of mys...
Node.js solves the problem of Chinese garbled cha...
As front-end engineers, IE must be familiar to us...
In this article, we sorted out the startup proces...
1. Server setup The remote repository is actually...
This article shares the specific code of jQuery t...
This article shares with you a small Demo that ad...
This article example shares the specific code for...
Table of contents Preface What does yarn create d...
Implementation ideas: Use text-shadow in CSS to a...
Before talking about CSS priority, we need to und...
First, start MySQL in skip-grant-tables mode: mys...
1. Introduction pt-query-digest is a tool for ana...
I recently joined a new company and found some mi...