Results 1 to 4 of 4

Thread: How to List command line history with timestamp

  1. #1
    Join Date
    Apr 2009
    Posts
    65

    How to List command line history with timestamp

    Have been working on Redhat 9 for about 6 months. I often write little batch scripts, sometimes just as a way to save a lengthy command line. I 'm just wondering, if it's possible to capture command line entries ( bash etc ) into a text file with a timestamp. When used, this will make libcurl attempt to figure out the timestamp of the remote file, By default, history do not append with timestamp, but it is easy to configure it to display timestamp, you just need to set one environment variable HISTTIMEFORMAT." Does anyone know about this.

  2. #2
    Join Date
    Oct 2008
    Posts
    167

    Re: How to List command line history with timestamp

    You can use the HISTFILE and HISTFILESIZE variables to keep a command log. History is a common command for shell to list out all the executed commands. It is very useful when it comes to investigation on what commands was executed that tear down the server. If the command line history could provides the date time of the commands being executed, that may really narrow down the scope of the user actions that cause the server malfunction.

  3. #3
    Join Date
    Dec 2008
    Posts
    161

    Re: How to List command line history with timestamp

    You already have such a file in .bash_history and you can call up your previous commands with up arrow. If the command line history could provides the date time of the commands being executed, that may really narrow down the scope of the user actions that cause the server malfunction. When used, this will make libcurl attempt to figure out the timestamp of the remote file, and if that is available make the local file get that same timestamp. By default, history do not append with timestamp, but it is easy to configure it to display timestamp, you just need to set one environment variable HISTTIMEFORMAT. HISTTIMEFORMAT takes format string of strftime.

  4. #4
    Join Date
    Dec 2008
    Posts
    161

    Re: How to List command line history with timestamp

    Check out the strftime manual to choose and construct the timestamp that suit your taste. My favorite is %F %T . I would suggest you to put the export into ~/.bash_profile as well as /root/.bash_profile. In case you do not have .bash_profile, you can choose to put into ~/.bashrc. It works on Windows Server 2003 and Windows Vista, however I don't know if non-default regional settings change the behavior of these variables.

Similar Threads

  1. List of Windows XP and Windows Vista Command line Shortcuts
    By Pyrotechnic in forum Tips & Tweaks
    Replies: 6
    Last Post: 15-10-2010, 08:18 AM
  2. xcopy command line together with wmplayer command line
    By Aislinn in forum Operating Systems
    Replies: 5
    Last Post: 31-03-2010, 12:13 PM
  3. Replies: 3
    Last Post: 03-09-2009, 05:41 PM
  4. Replies: 1
    Last Post: 18-05-2007, 01:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •