Operating System - HP-UX
1754942 Members
3203 Online
108827 Solutions
New Discussion юеВ

Shell history not being written to specified history file

 
Peter Nikitka
Honored Contributor

Re: Shell history not being written to specified history file

Hi,

remove the default historyfile and retry again - perhaps this helps.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Scott Lindstrom_2
Regular Advisor

Re: Shell history not being written to specified history file

Brett - I am having the *exact* same problem on only one of our servers. Did you ever get a resolution?

I have checked all the items in this thread and nothing seems to be causing the problem.

Scott
Bill Hassell
Honored Contributor

Re: Shell history not being written to specified history file

> date>>$HISTFILE

I believe that this is the problem. The POSIX shells (like ksh, HP's sh, bash, etc) create specialized binary file for the shell history. 99% of the file is ASCII but there are binary codes scattered throughout the file. The first 2 characters in a .sh_history file are SOH (CTRL-A or 0x01). You can see the effect when you edit .sh_history with vi (to remove traces of a mistake). Once edited, the history command (or fc -l) reports blank line numbers in the file. It appears that deleting or adding a line corrupts the file.

This problem comes up when trying to add a timestamp to the shell history file.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Shell history not being written to specified history file

>Bill: I believe that this is the problem.

Didn't I say that above? :-)
Scott Lindstrom_2
Regular Advisor

Re: Shell history not being written to specified history file

Let me try converting to the "print -s" method. While we have printed the datestamp directly to the file for years I can see how that could/would corrupt the file.

But would that cause the system to write history to .sh_history rather than whatever is in $HISTFILE? (A rhetorical question I guess).
Dennis Handly
Acclaimed Contributor

Re: Shell history not being written to specified history file

>Scott: But would that cause the system to write history to .sh_history rather than whatever is in $HISTFILE?

I'm not sure, why would the shell would check the file for validity?
Are you exporting HISTFILE at the top of ~/.profile? Does /etc/profile cause any history to be written sooner?
The documentation isn't clear when you can change/export it.
Sundar G
Frequent Advisor

Re: Shell history not being written to specified history file

Brett,
It works perfectly in my Itanium, 11.31 server, but "what /bin/ksh" shows a different date, "B.11.31 Oct 1 2008 01:54:10".

Might be bcause of the version