Set the execution time for Linux to view historical commands

Source: Internet
Author: User
When you set Linux to view the execution time of historical commands, we all know that on the Linux platform, you can use the history command to view the commands that have been recently executed. However, the history command displays only numbers and commands by default, I only know that the command is recently executed, but I do not know the specific execution date, time... when you set Linux to view the execution time of historical commands, we all know that on the Linux platform, you can use the history command to view the commands that have been recently executed. However, the history command displays only numbers and commands by default, I only know that the command was executed recently, but I do not know the specific execution date, time, minute, and second. sometimes it is inconvenient to find evidence, for example: 352 exit 353 history 354 vi/etc/profile 355 history The following describes how to make the history command display the specific execution time of the recently executed command. the steps are as follows: 1. edit the/etc/profile file as the ROOT user and add the following content to it (I usually add it at the end): export HISTTIMEFORMAT = "% Y-% m-% d % H: % M: % S" note: add a space between the "quotation marks" and "S" at the end, separate the datetime and history commands with spaces. 2. log out of the system and log on again. note: the historical commands executed before step 1 are displayed as the execution time of step 2 after you log on again, the following command will display the correct actual execution time. 3. view the result (it will take effect for any user): (1) try the result with the ROOT user: [root @ oraclelinux ~] # History 354 23:50:00 vi/etc/profile 355 23:50:12 history 356 23:50:14 exit 357 00:04:32 history [root @ oraclelinux ~] # (2) Try it out for ORACLE users: [root @ oraclelinux ~] # Su-oracle [oracle @ oraclelinux ~] $ History 321 00:06:33 history 322 00:07:05 exit 323 00:19:23 history
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.