HISTSIZE environment variable problem

Hi All,

I am connecting to a sun solaris 5.9 unix (korn shell) server using the x terminal. There is some problem with the HISTORY File where the HISTSIZE env variable is not working. Although the HISTSIZE is set to 20 already but the HISTORY file keep increasing and exceeded the size.
There is another option where I just tail -20 $HISTFILE and put in into a temporary file before mv it to the name $HISTFILE but strangely this will actually just clear off the $HISTFILE when I run the script on the .kshrc file.
This script is working when I test it in command line.

I hope you all can help, thanks

Regards,
Kenneth

You are cross posting. You have two threads with the same topic. One is here and the other is here. Please do not do this. It is against the rules.

Hi All,

Sorry, actually this is the first time i use this forum and I post it in wrong section. Please help to remove the message in another section.
One thing I want to ask why I notice that the $HISTSIZE actually is to control the size of HISTORY instead of the $HISTFILE in the korn shell. How can I control the size of $HISTFILE

Hope you all can help

Thanks,
Kenneth

I have deleted the duplicate thread.

HISTSIZE controls the size of the history list. HISTFILE controls where the history is stored. But they must be set when ksh first does something with the history list. Setting them later has no effect. Exporting them into the environment ensures that they will affect shells spawned later. But that won't stop the rule that each ksh process looks at them once and once during its lifetime. I don't know what "the HISTSIZE is set to 20 already" is supposed to mean. If you set that in the environment prior to invoking ksh, it should work. But most likely you are setting the variable in a startup file (thus after ksh starts to run) and you are setting too it late. Note that ksh writes functions into the history (unless nolog is on). Did you define a function prior to setting HISTSIZE?

I actually write export HISTSIZE=20 in the .kshrc file almost at the end just before the functions definition. If this is wrong, can you teach where to set the variable.
There is a line set -o nolog in the .kshrc just before a series of function definition.

Thanks for you help

regards,
Kenneth

With a login shell, /etc/profile and then ~/.profile are sourced first. Try setting HISTSIZE as the first thing.