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.
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.
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.
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.