Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to List command line history with timestamp

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 03-07-2009
Member
 
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.

Reply With Quote
  #2  
Old 03-07-2009
Member
 
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.
Reply With Quote
  #3  
Old 03-07-2009
Member
 
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.
Reply With Quote
  #4  
Old 03-07-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to List command line history with timestamp"
Thread Thread Starter Forum Replies Last Post
List of Windows XP and Windows Vista Command line Shortcuts Pyrotechnic Tips & Tweaks 6 15-10-2010 09:18 AM
xcopy command line together with wmplayer command line Aislinn Operating Systems 5 31-03-2010 01:13 PM
Problem: Command Line Option Syntax Error. Type Command /? For Help Nadeem MediaCenter 3 03-09-2009 06:41 PM
autorun.inf - shell\..\command with command line parameter doesn'twork kakii Windows XP Support 1 18-05-2007 02:24 AM


All times are GMT +5.5. The time now is 02:12 AM.