在history命令历史中增加执行的时间
history命令可以显示执行过的命令,我们还让history命令显示执行的时间。
将export HISTTIMEFORMAT='%F %T '命令放入家目录的.bash_profile中后,再用source命令更新.bash_profile文件或重新启动系统后就可以在history命令看到执行的时间了。
需要注意:%T后面需要留个空格,不然后就会与执行的命令连在一起了,看上去不美观。
详细的操作请看下面的命令:
[root@CentOS7 ~]# history 1 history 2 history -w 3 shutdown -r now 4 history [root@CentOS7 ~]# echo "export HISTTIMEFORMAT='%F %T '" >> .bash_profile [root@CentOS7 ~]# source .bash_profile [root@CentOS7 ~]# history 1 2021-01-31 21:28:03 history 2 2021-01-31 21:28:03 history -w 3 2021-01-31 21:28:03 shutdown -r now 4 2021-01-31 21:28:06 history 5 2021-01-31 21:29:21 echo "export HISTTIMEFORMAT='%F %T '>> .bash_profile 6 2021-01-31 21:29:37 echo "export HISTTIMEFORMAT='%F %T ' >> .bash_profile 7 2021-01-31 21:29:50 echo "export HISTTIMEFORMAT='%F %T '" >> .bash_profile 8 2021-01-31 21:30:02 source .bash_profile 9 2021-01-31 21:30:11 history

浙公网安备 33010602011771号