Find the answer to your Linux question:
Results 1 to 5 of 5
how to add time to history command, according to I checked internet, they said have to use this command Code: echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc source ~/.bashrc but ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    33

    How to set history command to show time that execute command

    how to add time to history command, according to I checked internet, they said have to use this command
    Code:
    echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
    source ~/.bashrc
    but on my computer still doesn't show time like they show me.

    Could you please help me how to add time to history command

  2. #2
    Just Joined!
    Join Date
    Jan 2011
    Location
    Fairfax, Virginia, USA
    Posts
    94
    Hi Lung,
    That should be good. Here is what I did here:
    Code:
    [brian@bmicek ~]$ export HISTTIMEFORMAT="%d/%m/%y %T "
    Then I did typed "history" and observed this:
    Code:
     1000  18/07/11 21:00:05 export HISTTIMEFORMAT="%d/%m/%y %T "
     1001  18/07/11 21:00:06 ls
     1002  18/07/11 21:00:12 history
    The change I made only applies to this one shell, but I think your command is good. Are you sure your shell is bash? To check, run a command like this:
    Code:
    [brian@bmicek ~]$ grep $USER /etc/passwd
    and look for /bin/bash as the last colon delimited field.

  3. #3
    Just Joined!
    Join Date
    Dec 2008
    Posts
    33
    After I run [brian@bmicek ~]$ grep $USER /etc/passwd
    root:0:0:root:/root:/bin/bash

  4. #4
    Just Joined!
    Join Date
    Jan 2011
    Location
    Fairfax, Virginia, USA
    Posts
    94
    Very interesting! Can you run this command please?
    Code:
    [brian@bmicek ~]$  echo $HISTTIMEFORMAT
    %d/%m/%y %T
    also:
    Code:
    [brian@bmicek ~]$ bash --version
    GNU bash, version 4.1.7(1)-release (x86_64-redhat-linux-gnu)
    Copyright (C) 2009 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    
    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

  5. #5
    Just Joined!
    Join Date
    Dec 2008
    Posts
    33
    I think The problem is The Version of Linux, I use SUSE linux 9.
    After I run echo $HISTTIMEFORMAT %d/%m/%y %T
    %d/%m/%y %T %d/%m/%y %T

Posting Permissions

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