Operating System - HP-UX
1754021 Members
6985 Online
108811 Solutions
New Discussion юеВ

.sh_history files growing by leaps and bounds

 
Christina Martin
Frequent Advisor

.sh_history files growing by leaps and bounds

our .sh_history files are HUGE. We have the HISTSIZE set at 128 but the system is not trimming the files at all.

Is anyone else experiencing this problem? Any suggestions?
8 REPLIES 8
Pete Randall
Outstanding Contributor

Re: .sh_history files growing by leaps and bounds

Danny,

I don't even set HISTSIZE and the largest I see on my systems is somewhere around 4K. Just how big is HUGE?


Pete

Pete
Hazem Mahmoud_3
Respected Contributor

Re: .sh_history files growing by leaps and bounds

Make sure that the HISTSIZE variable applies to everyone. Also, you can right a simple script to check for that and trim it down (use wc to find out number of lines, hence # of commands stored).

-Hazem
Christina Martin
Frequent Advisor

Re: .sh_history files growing by leaps and bounds

this particular .sh_history file is 9148322 (261208 lines)

This is a shared .sh_history file. I do understand about the 4 requirements that must exist before the file will be trimed. But even when all 4 requirements exist the file doesn't get trimmed.

Bill Hassell
Honored Contributor

Re: .sh_history files growing by leaps and bounds

Shared history file? Oops, the shell actually records some binary pointers in the file (usually invisible when you cat it) so .sh_history is not a simple ASCII file. With a single user ID, multiple logins will handle the .sh_history file correctly by using file locking (which is why NFS mounting of .sh_history doesn't always wrok). But if this file is shared among other user logins, I would expect problems such as you describe.

If you need to share this file, you'll need to use cron to trim it. But because the shell puts markers in it, simply zeroing the file may cause the history to display nothing but blank lines. Removing the file and recreating it seems to work OK.


Bill Hassell, sysadmin
Christina Martin
Frequent Advisor

Re: .sh_history files growing by leaps and bounds

Bill, thank you for your response! That works great for the shared .sh_history files. Any particular reason a NON shared .sh_history for root /home/root/.sh_history would be 32432 in size with 2441 lines?

HISTSIZE is not set in /etc/profile or /home/root/.profile.

grep /home/root /etc/passwd only displays the root user having use of the /home/root directory.

Thanks in advance.

Lisa
Bill Hassell
Honored Contributor

Re: .sh_history files growing by leaps and bounds

Make sure that /home is 755 permission and /home/root is at least 755 or better yet, 700 permission. And of course, root's .sh_history should be 600 along most other files in root's $HOME. You don't want other users casually browsing sysadmin files. If this is 11.0, make sure you have the latest POSIX shell patch. If root is using some other shell, change it back to /sbin/sh immediately. You'll have big problems in single user mode without /sbin/sh as your shell.


Bill Hassell, sysadmin
someone_4
Honored Contributor

Re: .sh_history files growing by leaps and bounds

great post.

richard
Ameet_HP
Frequent Advisor

Re: .sh_history files growing by leaps and bounds

Check .profile & rc files, those may be keeping 10/20 lines in sh_history everytime you login.