LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 04-27-2007, 03:02 PM   #1
jimmyjiang
Member
 
Registered: Jun 2006
Posts: 132

Rep: Reputation: 15
how to configue histoy command output?


hi,
I have couple redhat linux server's history command output is not right, how can I change it? the outpput is:

this is the right output I expected:

703 Apr/26 - 11:24:44 su
704 Apr/26 - 12:24:58 exit
705 Apr/27 - 15:05:35 ls -ltrh /home/oiprod/go_live/
706 Apr/27 - 15:05:41 pwd
707 Apr/27 - 15:41:05 history

this history's output date alway remain on Apr/04 , and time is not right too, how do I change it?
946 Apr/04 - 15:16:24 /usr/local/tomcat/bin/startup.sh
947 Apr/04 - 15:16:42 ls -las /usr/local/tomcat/webapps/
948 Apr/04 - 15:17:40 ls -las /usr/local/tomcat/work
949 Apr/04 - 15:18:07 /home/tomcat/rotation_add.sh
950 Apr/04 - 15:19:33 history
951 Apr/04 - 15:19:49 date
952 Apr/04 - 15:41:24 history
[root@96743-oi9 ~]# date
Fri Apr 27 15:56:58 EDT 2007
[root@96743-oi9 ~]#


and third one don't have date and time at all.
1007 tail -f /var/log/loadbalancer
1008 history
1009 histroy
1010 history
1011 man histroy
1012 man history
1013 history

thanks in advance!
 
Old 04-27-2007, 03:18 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You have to set the HISTTIMEFORMAT variable.

For example:
export HISTTIMEFORMAT=%c
will make it use your locale's preferred format.

"man strftime" will give you other format options.
 
Old 04-27-2007, 03:47 PM   #3
jimmyjiang
Member
 
Registered: Jun 2006
Posts: 132

Original Poster
Rep: Reputation: 15
I use env command to find the format at server has right output: HISTTIMEFORMAT=%h/%d - %H:%M:%S
so I did:
[root@83972-oi2 ~]# export HISTTIMEFORMAT=%h/%d - %H:%M:%S
-bash: export: `-': not a valid identifier
-bash: export: `%H:%M:%S': not a valid identifier
[root@83972-oi2 ~]#

what format should I put after %h/%d?

and also I checke the server with wrong date hisotry ooutput, it has the same HISTTIMEFORMAT=%h/%d - %H:%M:%S, so format is not the reason why it display the wrong time.
 
Old 04-27-2007, 04:03 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
It didn't understand your syntax - you need to encapsulate it in quotes:

export HISTTIMEFORMAT='%h/%d - %H:%M:%S '

That way it will know all of what follows is format. The above format is a little bizzare but does display so long as you put the quotes on it.

Make sure you're in a bash shell when typing "history". The above format has no meaning in other shells such as ksh.

That fact that you're always seeing April 4th makes me think somewhere you hard coded that as the date OR that you typed no commands on that login AFTER April 4th though "history" itself should appear with today's date if you set the variable correctly.
 
  


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
What is the command that use to get these output shinwai Linux - Newbie 2 08-31-2005 08:26 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM
how to configue X server soner Fedora 1 10-31-2004 01:18 PM
last -i command output praveenv Linux - Networking 2 08-18-2004 12:43 AM
last -i command output praveenv Linux - Networking 1 08-17-2004 06:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 09:17 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