Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.