LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-30-2007, 12:03 PM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Rep: Reputation: 30
History command with system date


Dear Friends ,

I need a command which helps to execute "history" command with system date ,

i.e.,

I can set the time in history so that I will get a better idea at what time the command was fired .

Plz help me to give some information about this ... ...
 
Old 09-30-2007, 12:17 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You have to define the environment variable HISTTIMEFORMAT. The format is expressed in the same way as the command date (see man date for details). For example, defining the following in your ~/.bashrc
Code:
export HISTTIMEFORMAT="%H:%M:%S - "
will give a history like
Code:
  208  18:10:57 - history
  209  18:10:58 - ls
  210  18:11:01 - cd
 
Old 10-01-2007, 12:26 PM   #3
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Original Poster
Rep: Reputation: 30
'history' command contains more logs, how to ?

Thx colucix for ur reply .
I have another question .


By default how many logs the 'History' command contains ?

If I want to see the logs of history command
before 6 month (or more) ago , then what will I do ?

waiting for ur kind reply ... ..
 
Old 10-01-2007, 01:15 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by shipon_97 View Post
By default how many logs the 'History' command contains ?
It depends from other environment variables related to history. HISTSIZE sets the number of commands saved in a single session, HISTFILESIZE sets the max number of commands stored in the history file. Look at these environment variables in your setup: most likely they will be set to 1000 (default values).
Quote:
If I want to see the logs of history command
before 6 month (or more) ago , then what will I do ?
It is not a good idea to increase the HISTFILESIZE to a very high value, since the file .bash_history will increase in size. If the purpose is to archive past commands somewhere in a text file, you may think to periodically (e.g. once a week) copy .bash_history or append its content to a backup file. You can do this automatically by means of a crontab job.
 
Old 12-26-2009, 12:53 AM   #5
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Original Poster
Rep: Reputation: 30
history with date command in AIX platform !!

Thx colucix ,

I have another problem in AIX 5.3 server platform . By default when I use "history -t" then it shows the command history using time/date .



$ history -t
886 2009/12/23 13:04:33 :: bash
887 2009/12/23 16:03:01 :: bash
888 ? :: ls
889 ? :: sh rmanincremental.sh
890 ? :: exit
891 2009/12/24 09:20:11 :: bash
892 2009/12/24 09:24:00 :: bash
893 2009/12/24 09:25:03 :: bash
894 2009/12/24 10:19:43 :: bash
895 2009/12/24 14:49:20 :: bash
896 ? :: ls
897 ? :: sh rmanfull.sh
898 ? :: df -g
899 2009/12/26 09:32:28 :: bash
900 2009/12/26 09:54:40 :: bash
901 2009/12/26 11:10:18 :: history -t


But the problem is , some command (which is not related the o/s command) are not display the date/time value , (it shows ? sign instead) . Would you plz help me How can I add date/time value with this command in AIX unix platform ?

Waiting for kind reply ... ...
 
Old 12-26-2009, 03:41 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Sorry, but I'm not an expert on AIX systems. By the way, did you give a look at the answers in this other thread of yours? Cheers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Setting system date and time affecting the clock and date on BIOS satimis Ubuntu 7 09-21-2007 09:02 AM
History command amer_58 Linux - General 5 06-24-2005 01:26 PM
Command history? King4lex Linux - Newbie 4 09-03-2004 09:35 PM
History command, How to get the date? philipina Linux - General 2 08-05-2004 06:58 PM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 01:09 PM


All times are GMT -5. The time now is 11:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration