In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to let the history command display the date and time in linux. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
By default, the history command directly displays the command executed by the user without printing the date and time when the command was run, even if the history command records that time.
When you run the history command, it checks an environment variable called HISTTIMEFORMAT, which indicates how to format the time recorded in the output history command.
If the value is null or is not set at all, it does not display the date and time, as most systems display by default.
HISTTIMEFORMAT uses strftime to format the display time (strftime-converts dates and times to strings). The history command outputs the date and time to help you track the problem more easily.
% T: replace with time (% H:%M:%S).
% F: equivalent to% Y-%m-%d (ISO 8601 2000 standard date format).
The following is the default output of the history command.
# history 1 yum install-y mysql-server mysql-client 2 service mysqld start 3 sysdig proc.name=sshd 3 sysdig-c topprocs_net 5 sysdig proc.name=sshd 6 sysdig proc.name=sshd | more 7 sysdig fd.name=/var/log/auth.log | more 8 sysdig fd.name=/var/log/mysqld.log 9 sysdig-cl 10 sysdig-I httplog 11 sysdig-I proc_exec_time 12 sysdig-I topprocs_cpu 13 sysdig-c topprocs_cpu 14 sysdig-c tracers_2_statsd 15 sysdig-c topfiles_bytes 16 sysdig- C topprocs_cpu 17 sysdig-c topprocs_cpu "fd.name contains sshd" 18 sysdig-c topprocs_cpu "proc.name contains sshd" 19 csysdig 20 sysdig-c topprocs_cpu 21 rpm-import https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public 22 curl-s-o / etc/yum.repos.d/draios.repo http://download.draios.com/stable/rpm/draios.repo 23 yum install-y epel-release 24 yum update 25 yum makecache 26 yum -y install kernel-devel-$ (uname-r) 27 yum-y install sysdig 28 sysdig 29 yum install httpd mysql 30 service httpd start
Depending on the requirements, there are three different ways to set environment variables.
Temporarily set the environment variable for the current user
* set environment variables for current / other users
* set environment variables for all users
Note: don't forget to put a space before the single quotation mark, otherwise the output will be very confusing.
Method 1:
Run the following command to temporarily set the HISTTIMEFORMAT variable for the current user. This will remain in effect until the next restart.
# export HISTTIMEFORMAT='%F% T 'method 2:
Add the HISTTIMEFORMAT variable to the .bashrc or .bash _ profile file to make it take effect.
# echo 'HISTTIMEFORMAT= "% F% T" > > ~ / .bashrc or # echo' HISTTIMEFORMAT= "% F% T" > ~ / .bashrc
Run the following command to make the changes in the file take effect.
# source ~ / .bashrc or # source ~ / .bash_profile method 3:
Add the HISTTIMEFORMAT variable to the / etc/profile file to make it effective for all users.
# echo 'HISTTIMEFORMAT= "F% T" > / etc/profile
Run the following command to make the changes in the file take effect.
# source / etc/profile
The output is as follows:
# history 1 2017-08-16 15:30:15 yum install-y mysql-server mysql-client 2 2017-08-16 15:30:15 service mysqld start 3 2017-08-16 15:30:15 sysdig proc.name=sshd 4 2017-08-16 15:30:15 sysdig-c topprocs_net 5 2017-08-16 15:30:15 sysdig proc.name=sshd 6 2017-08-16 15:30:15 sysdig proc.name=sshd | more 7 2017-08-16 15:30:15 sysdig fd.name=/var/log / auth.log | more 8 2017-08-16 15:30:15 sysdig fd.name=/var/log/mysqld.log 9 2017-08-16 15:30:15 sysdig-cl 10 2017-08-16 15:30:15 sysdig-I httplog 11 2017-08-16 15:30:15 sysdig-I proc_exec_time 12 2017-08-16 15:30:15 sysdig-I topprocs_cpu 13 2017-08-16 15:30:15 sysdig-c topprocs_cpu 14 2017-08-16 15:30 : 15 sysdig-c tracers_2_statsd 15 2017-08-16 15:30:15 sysdig-c topfiles_bytes 16 2017-08-16 15:30:15 sysdig-c topprocs_cpu 17 2017-08-16 15:30:15 sysdig-c topprocs_cpu "fd.name contains sshd" 18 2017-08-16 15:30:15 sysdig-c topprocs_cpu "proc.name contains sshd" 19 2017-08-16 15:30:15 csysdig 20 2017-08-16 15:30:15 sysdig-c topprocs_ Cpu 21 2017-08-16 15:30:15 rpm-- import https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public 22 2017-08-16 15:30:15 curl-s-o / etc/yum.repos.d/draios.repo http://download.draios.com/stable/rpm/draios.repo 23 2017-08-16 15:30:15 yum install-y epel-release 24 2017-08-16 15:30:15 yum update 25 2017-08- 16 15:30:15 yum makecache 26 2017-08-16 15:30:15 yum-y install kernel-devel-$ (uname-r) 27 2017-08-16 15:30:15 yum-y install sysdig 28 2017-08-16 15:30:15 sysdig 29 2017-08-16 15:30:15 yum install httpd mysql 30 2017-08-16 15:30:15 service httpd start is all the content of the article "how to make the history Command display date and time in linux" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.