In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Linux's Tips for viewing History Records with timestamps
Anyone familiar with bash must know that you can use history to output historical commands that you have entered, such as
[root@servyou_web ~] # history | more 6. / test.sh 7 vim test.sh 8. / test.sh
But only the command is shown here, not the time when the command was executed, because there is no save time in the ~ /. Bash_history where the history command is saved.
Timestamp history by setting the environment variable export HISTTIMEFORMAT= "% F% T `whoami`"
[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 1913 root 02 root. / test.sh 1021 -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
You can see that the timestamp of the history command has been added, but not in .bash _ history. In fact, this time record is saved in the memory of the current shell process, and if you logout and log back in, you will find that the timestamps of the commands you executed the last time you logged in are all the same value, that is, the time of logout.
However, 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 quit, so these can be retained for a long time. You can also use echo 'export HISTTIMEFORMAT= "% F% T `whoami`" > / etc/profile and then source OK
Summary
The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.