LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-05-2008, 10:50 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
check date to run the command


I use the command "history" can show all command that I used perviously , but if I want to know when ( what time ) I used this command , can advise what can i do ? thx
 
Old 06-05-2008, 11:47 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
man history

" If the shell variable HISTTIMEFORMAT is set and not null, it is used as a format string for
strftime(3) to display the time stamp associated with each displayed history entry.
No intervening blank is printed between the formatted time stamp and the history line.
"
 
Old 06-05-2008, 11:58 PM   #3
Anithen
Member
 
Registered: Aug 2003
Location: Florida
Distribution: Slackware 12, Slackware 12.1, Slackware 12.2
Posts: 105

Rep: Reputation: 15
Hmmm, the man page mentions this briefly, but it looks like you would need to do some programming to perhaps build a utility to utilize this. Searching on google I could not find anything, but in the man page I see this:

time_t history_get_time (HIST_ENTRY *)
Return the time stamp associated with the history entry passed as the
argument

Again, I have not figured out how to use that option, but it seems like you have to use it with some custom code. Good luck, man.

I'd love to figure out how you get this functionality.
 
Old 06-06-2008, 01:10 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Not so obscure...
Quote:
If the shell variable HISTTIMEFORMAT is set and not null, it is used as a format string for strftime(3)
This tells you that HISTTIMEFORMAT is a shell variable, which is used as a format string with the rules used by the C function strftime, or if you prefer by the date command. So, you have simply to do something like
Code:
export HISTTIMEFORMAT="%Y%m%d %H:%M:%S "
put this in your ~/.bashrc to make it permanent and magically your history file will be populated by dates in the format you have chosen.
 
Old 06-06-2008, 04:10 AM   #5
Anithen
Member
 
Registered: Aug 2003
Location: Florida
Distribution: Slackware 12, Slackware 12.1, Slackware 12.2
Posts: 105

Rep: Reputation: 15
Hey, colucix. Thanks for the information on how to use the info in the man page. I was totally misinterpreting it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to check the password expiry date of a user? binary_0011 Other *NIX 1 06-04-2008 01:37 AM
LXer: Check if Compiz will run well on your Linux Box with Compiz Check LXer Syndicated Linux News 0 05-05-2008 01:20 AM
how to check the date for the user ID created? dwarf007 Linux - Security 1 08-22-2007 04:00 AM
How to check User ID creation Date? dwarf007 Linux - Security 1 08-22-2007 02:18 AM
Check for invalid date Blackout_08 Programming 3 06-07-2006 08:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration